Headers and Footers
Headers and footers are a great way to add branding and information to the top and/or bottom of your document.
Add headers and footers
In your HTML, add an element to the <body>
to become your header or footer. For clarity, we’re using the <header>
HTML element here for headers, and the <footer>
HTML element for footers.
Now, create a template file called styles.css
and add the following styles to enable the header and footer behaviour. Visit the Margin Boxes guide for other placements.
Different headers and footers
You may not want to have the same header and footer on every page of your document. You can easily change or hide the header for certain page(s) by adding different <header>
elements at the relevant positions in the document that you want to start using them from.
In your styles.css
template file, which you’ll need to create if you haven’t already.
As the rendering engine processes the pages sequentially, it picks up a new header if one is present in that page. If no new <header>
elements are found on that page, it continues with the most recently used header.
In your HTML file, you can add header variations for each section. Sections here act as pages, using the CSS above.
Include page numbers
To simply show page numbers on all pages, visit our Page Numbers guide.
To include page numbers in your headers and footers, you can use the counter
function in CSS.
Your styles.css
file will need to be updated to look this: