Can organizations define page headers and footers in DITA templates?
In DITA templates, organizations can define page headers and footers to include consistent and structured information at the top and bottom of each page in the published output.
Page headers and footers are essential components in DITA templates as they allow organizations to add standardized content, such as titles, author information, page numbers, and more, to the top and bottom of each page in the published output. These elements ensure consistency in the layout and presentation of content.
In DITA, page headers and footers are typically defined within the stylesheet or template used for publishing, often through Cascading Style Sheets (CSS) or other styling mechanisms.
CSS Styles:
CSS styles can be created to define the appearance and content of page headers and footers.
Styles can specify elements for the header and footer sections, as well as their positioning and formatting.
For example:
@page {
size: 8.5in 11in;
margin: 1in;
}
@page :first {
margin-top: 2in;
}
@page :left {
@top-left {
content: "Left header text";
}
@bottom-left {
content: "Left footer text";
}
}
@page :right {
@top-right {
content: "Right header text";
}
@bottom-right {
content: "Right footer text";
}
In this example, the CSS defines the content for headers and footers, including the text to be displayed on the top left, top right, bottom left, and bottom right of each page.
Template Configuration:
DITA publishing tools or systems may provide options for configuring page headers and footers.
These configurations can often be specified in the template settings.
For example:
<page-template>
<page-header>
<top-left>Left header text</top-left>
<top-right>Right header text</top-right>
</page-header>
<page-footer>
<bottom-left>Left footer text</bottom-left>
<bottom-right>Right footer text</bottom-right>
</page-footer>
</page-template>
In this example, the template configuration defines the content for the page headers and footers.
When a DITA document is processed for publishing, these definitions for page headers and footers are applied to generate consistent headers and footers throughout the document, ensuring that information is presented uniformly across pages.
Example:
Suppose an organization wants to include the document title in the page header and the page number in the page footer of their published DITA content. They can create CSS styles or use template configurations to define these elements. Here’s an example of how it might look in CSS:
@page {
size: 8.5in 11in;
margin: 1in;
}
@page :left {
@top-left {
content: string(dita-title);
}
@bottom-center {
content: counter(page);
}
}
In this CSS example, the string(dita-title) function retrieves the document title, and the counter(page) function inserts the page number into the header and footer sections, respectively.