CSS page headers - how to use print margins?

I can get a header to print on each page, but I'm new to print margins. I thought the @page css would work, but it does not seem to affect page margins. If I set the margins on the body, it works on page one, but subsequent pages start the top margin at the default, putting the header over top of the text.

.header {  
 position: fixed;  
 top: 0;  
@page {  
 size: 11in 17in;  
 margin-left: 1in;  
 margin-right: 1in;  
 margin-top: 1in;  
 margin-bottom: 1in;  

<span class=header>This is the header</span>  
This is the text of the document. (repeat until I get to page 2)  


Printing support by all browsers is very poorly supported with horrendous bugs in many popular browsers that have gone unfixed for years.

The short answer is to avoid HTML/CSS printing if you need to ensure a specific layout. Use PDF, possibly dynamically generated on-demand. There's various PDF generator APIs such as iTextSharp. It's possible to print from Flash, but only if Flash is installed and working (i.e. no Flashblock, iOS).

HTML/CSS printing should be restricted to simple layouts. Form printing is a nightmare with fieldset & legend support being especially problematic (particularly on Firefox). Interestingly printing support is best on the internet explorers.

The CSS3 printing support specification hasn't been completed and is some time off.

General principles:

  • No backgrounds or background CSS images are supported (by default - users can change their browser settings for an intranet application). Only foreground images print.

  • Widths need to be fluid as page sizes vary around the planet. US Letter format is shorter and wider than A4 layout

  • All browsers support printing in different ways. Bugs are legion.

  • Test using print preview.

Need Your Help

UIActionSheet on iPad is not showing cancel button

objective-c ipad ios4 uiactionsheet

I am trying to show cancel button in UIActionSheet but it's not showing, is that an acceptable behavior? please advice.

100% width footer without wrapper

html5 css3

I was wondering if it was possible to have a 100% width footer for a 980px content without any #wrappers or Divs in the code? I'm a fan of camendesign's ethos, but due to the method of having the b...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.