1

I want to include the page title in the footer of every printed page, but I can't figure out how to do it. Basically, I'm expecting to have to do something like this:

@page {
  @bottom-right {
    content: attr(title);
  }
}

But of course that doesn't work. AFAICS, I either need to set an attribute on @page that I can reference using attr, or I need to use some other method to refer to specific content (i.e. title in my page). I am using the same CSS on multiple pages with different titles, so I can't just hard code it.

aquavitae
  • 17,414
  • 11
  • 63
  • 106

2 Answers2

1

Since the attr() Function only works on the selected element it is not possible to get the title of the page to be used in the footer.

If you create your pages dynamically put the title directly in the footer, otherwise use javascript

Jens W
  • 188
  • 6
  • Thanks. I realise that `attr` won't work, but how do I put it in the footer? I suspect I'm missing something really basic here but I don't know what... – aquavitae Nov 13 '14 at 08:05
  • As far as i know you can't do this kind of DOM Manipulation with css. Do you have a javascript library included in you project. – Jens W Nov 13 '14 at 08:10
  • No, for various reasons I'm not using any JS on this project. My fallback would be to write the css directly in a ` – aquavitae Nov 13 '14 at 08:15
  • Read the comments of misterManSam there is everything you need. But it seems that there is no 100% solution for printing footers on every page. – Jens W Nov 13 '14 at 08:42
0

How about something like this:

<div id="myTitle"></div>


<script type="text/javascript">
  document.getElementById("myTltle").innerHTML="The Page Title is:  "+document.title;
</script>
Jim VanPetten
  • 413
  • 3
  • 11