Is there a technique for adding a text footer the bottom of each page when it is printed? For example “Copyright My Company 2010” – I know there is probably a way to do this with a background image using CSS, but I would really like to use text for this portion so the client can edit it. Any ideas?
Share
CSS doesn’t have any notion of page media, so it’s going to be impossible to guarantee where the page breaks are going to occur naturally.
EDIT As pointed out below, CSS 2.1 did introduce
@pageas a way to deal with paged media, but it was never implemented across the common browsers. So, as I wrote above, it doesn’t exist, although that’s not technically true.You can set hard page breaks, e.g. by placing a
<div class="page-break">at the approximate locations. You can then style it withpage-break-before:alwaysto ensure that a break happens there.There’s also a
page-break-afterproperty; but then you don’t know how far down the page the element starts. So, when you need to position it, the only thing you can use isposition:absolute;bottom:0which wouldn’t fix it to the page media, but to the bottom of the whole document.If you use
page-break-beforethen you know it always appears at the top of the page. Then, you can useposition:absolutewithout giving atoporbottom, which results in only taking it out of the document flow. Then, giving it a height of 720pt (10 inches) means you have a bottom edge that you can position content against.Here’s how I would tackle it:
However, I have no idea how well browsers actually support this in reality. I remember playing with page breaks a while back, and ended up giving up because I couldn’t get them to work reliably enough. I suspect it’s still either impossible or very hackish and unreliable.