Fixed Header And Footer Examples For Essays

previous   next   contents   index

12Paged media

12.1 Introduction to paged media

Paged media -- paper, transparencies, computer screens that display pages, etc. -- differ from scrolled media in that formatting algorithms for pages must account for page breaks.

To handle page breaks, CSS2 extends two previous models:

  1. The   extends the box model to allow authors to specify the size of a page, its margins, etc.
  2. The   extends the visual flow model to account for page breaks. In the page model, the canvas is the page box.

The page model specifies how a document is formatted within a rectangular area -- the page box -- that has a finite width and height. The page box is an abstract rectangle that does not necessarily correspond to the   where the document will ultimately be rendered (paper, transparency, screen, etc.).

The CSS page model specifies formatting in the page box, but it is the user agent's responsibility to transfer the page box to the sheet. Some transfer possibilities include:

  • Transferring one page box to one sheet (e.g., single-sided printing).
  • Transferring two page boxes to both sides of the same sheet (e.g., double-sided printing).
  • Transferring N (small) page boxes to one sheet (called n-up  printing).
  • Transferring one (large) page box to N x M sheets (called "tiling").
  • Printing signatures (a group of pages printed on a sheet, which, when folded and trimmed like a book, appear in their proper sequence).
  • Printing one document to several output trays.
  • Transferring to a file.

This document does not specify how user agents transfer page boxes to sheets. It does allow users to provide the user agent (often through a dialog box) with information about the size of the sheet and the orientation of the transfer (see the 'size' property).

12.2Page breaks

The following sections explain page formatting in CSS2. Four properties indicate where the user agent may or should break pages, and on what page (left or right) the subsequent content should resume. Each page break ends the current page box and begins the next.

These properties have been designed to support the PRINT  medium, but can also be applied to other paged media, for example PROJECTOR  medium.

12.2.1 Page break properties: 'page-break-before', 'page-break-after', 'orphans', and 'widows'

'page-break-before'

Property name:'page-break-before' 
Value:auto | always | avoid | left | right
Initial:auto
Applies to:block-level and inline elements except those in tables
Inherited:no
Percentage values:N/A

'page-break-after'

Property name:'page-break-after' 
Value:auto | always | avoid | left | right
Initial:auto
Applies to:block-level and inline elements except those in tables
Inherited:no
Percentage values:N/A

Values for these properties have the following meanings:

auto
Neither force nor forbid a page break before (resp., after) the element
always
Always force a page break before (resp., after) the element
avoid
Avoid a page break before (resp., after) the element.
left
Force one or two page breaks before (resp., after) the element so that the next page to be formatted is a left page.
right
Force one or two page breaks before (resp., after) the element so that the next page to be formatted is a right page.

When both properties apply, 'always', 'left', and 'right' take precedence over 'avoid'. See the section on allowed page breaks for the exact rules on how these values force or suppress a page break.

These properties specify the minimum number of lines of a paragraph that must be left at the bottom ('orphans') and top ('widows') of a page.

12.2.2Allowed page breaks

In the normal flow, page breaks can occur at the following places:

  1. In the vertical margin between block-level elements. When a page break occurs here, the margin disappears (becomes zero).
  2. Between lines inside a block-level element.

These breaks are subject to the following rules:

  1. Breaking at (1) is only allowed if the 'break-after' and 'break-before' properties of all the elements that meet at this margin allow it, which is when at least one of them has the value 'always', 'left', or 'right', or when all of them are 'auto'.
  2. Breaking at (2) is only allowed if the number of lines between the break and the start of the block is 'orphans' or more, and the number of lines between the break and the end of the block is 'widows' or more.

There is an exception to both rules:

  1. Breaking at (1) and (2) is also allowed if, between the last page break and the next one that would be allowed under (A) and (B), there is so much content that it can't fit on a page.

Page breaks cannot occur inside positioned elements.

12.2.3 Forced page breaks

A page break must occur at (1) if, among the 'break-after' and 'break-before' properties of all the elements that meet at this margin, there is at least one with the value 'always', 'left', or 'right'.

12.2.4 "Best" page breaks

CSS does not define which of the page breaks allowed by (A), (B), or (C) should be used. In particular, CSS does not forbid a UA from breaking at every possible break point, or not to break at all. But CSS does recommend that UAs observe the following heuristics (while recognizing that they are sometimes contradictory):

  • Break as few times as possible.
  • Make all pages that don't end with a forced break appear to have about the same height.
  • Avoid breaking inside a block that has a border.
  • Avoid breaking inside a table.
  • Avoid breaking inside a floating element

Suppose, for example, that 'orphans'=4, 'widows'=2, and there are 20 lines available at the bottom of the current page:

  • If a paragraph at the end of the current page contains 20 lines or fewer, it should be placed on the current page.
  • If the paragraph contains 21 - 22 lines, the second part of the paragraph must not violate the 'widows' constraint, and so the second part must contain exactly two lines
  • If the paragraph contains 23 lines or more, the first part should contain 20 lines and the second part the remaining lines.

Now suppose that 'orphans'=10, 'widows'=20, and there are 8 lines available at the bottom of the current page:

  • If a paragraph at the end of the current page contains 8 lines or less, it should be placed on the current page.
  • If the paragraph contains 9 or more lines, it cannot be split (that would violate the orphan constraint), so it should move as a block to the next page.

12.3Page boxes: the @page rule

CSS2 allows authors to specify the dimensions of the page box, the margins, and several other properties relative to each page. However, since some document languages (e.g., HTML) do not define elements that represent "the page", these properties are specified for an entire document via the @page  rule.

For example, the following @page rule sets the margins of the page to 2cm.

@page { margin: 2cm }

Declarations inside the curly braces of the @page rule apply to every page of a document. These declarations are said to be in the page context , and they describe the page box into which the elements of the document are flowed according to the page model.

The page context allows the 'size' property to set the size of the page box and the 'marks' property to set crop and cross marks.

12.3.1Page margins

In addition, the following page margin properties, defined for the box that surrounds each element, apply within the page context:

The diagram below shows the relationships between the sheet, page box, and page margins:

Note that the page margins are included in the page box.

Note. In the future, border properties and padding properties may also be allowed in the page context.

The CSS2 rules for collapsing vertical margins apply to page margins as well. For example, the margin of the first element box on a page will collapse with the page margin.

The page context has no notion of fonts, so 'em' and 'ex' units are not allowed. Percentage values on the margin properties are relative to the dimensions of the page box. All other units associated with the respective CSS2 properties are allowed.

Due to negative margin values (either on the page box or on elements) or absolute positioning content may end up outside the page box, but this content may be cut -- by the user agent, the printer, or ultimately the paper cutter.

12.3.2 Page size: the 'size' property

'size'

Property name:'size' 
Value:<length>{1,2} | auto | portrait | landscape
Initial:auto
Applies to:page context
Inherited:N/A
Percentage values:N/A

This property specifies the size and orientation of a page box.

The size of a page box may either be "absolute" (fixed size) or "relative" (scalable, i.e., fitting available sheet sizes). Relative page boxes allow user agents to scale a document and make optimal use of the target size. Absolute page boxes ensure precise formatting when that is the author's prerogative.

Three values for the 'size' property create a relative page box:

auto
The page box will be set to the size and orientation of the target sheet. This is the initial value of the property.
@page { size: auto; margin: 10%; }

In the above example, the outer edges of the page box will align with the target. (Since 'auto' is the initial value on 'size', it is normally not necessary to set this value.) The percentage value on the 'margin' property is relative to the target size so if the target is 21.0cm x 29.7cm (i.e., A4), the margins are 2.10cm and 2.97cm.

landscape
The page box will have the same size as the target, and the normal direction of print occurs across the largest dimension of the target. Thus, the target orientation will be ignored.
portrait
the page box will have the same size as the target, and the normal direction of print occurs across the shortest dimension of the target. Thus, the target orientation will be ignored.

Explicit length values for the 'size' property create an absolute page box. If only one length value is specified, it sets both the width and height of the page box (i.e., the box is a square). Since the page box has no "parent", percentage values are not allowed on the 'size' property.

For example:

@page { size: 8.5in 11in; /* width height */ }

The above example set the width of the page box to be 8.5in and the height to be 11in. The page box in this example requires a target size of 8.5"x11" or bigger to be printed.

User agents may allow users to control the transfer of the page box to the sheet (e.g., rotating an absolute page box that's being printed).

Rendering page boxes that do not fit a target sheet 

If page box does not fit the target sheet dimensions, the user agent may choose to:

  • Rotate the page box 90° if this will make the page box fit.
  • Scale the page to fit the target.

The user agent should consult the user before performing these operations.

When the page box is smaller than the target size, the user agent is free to place the page box anywhere on the sheet. However, it is recommended that the page box be centered on the sheet since this will align double-sided pages and avoid accidental loss of information that is printed near the edge of the sheet.

Note. Typically, 8.5"x11" sheet size will be available in North America, while printers in other parts of the world are more likely to have the A4 sheet size available.

12.3.3 Crop marks: the 'marks property

'marks'

Property name:'marks' 
Value:crop || cross | none
Initial:none
Applies to:page context
Inherited:N/A
Percentage values:N/A

In high-quality printing, various marks are often added outside the page box. Crop marks  indicate where the page should be cut and cross marks  (also known as register marks or registration marks) are used to align sheets. This property describes what marks should be printed on the page outside the outer edges of the page box.

Marks are only visible on absolute page boxes. In relative page boxes, the page box will be aligned with the target and the marks will be outside the printable area.

The size, style, and position of cross marks depends on the user agent.

12.3.4 Left and right pages

When printing double-sided documents, the page boxes on left and right pages should be different. This can be expressed through two CSS pseudo-classes that may be defined in the page context.

All pages are automatically classified by user agents into either the :left  or :right  pseudo-class.

@page :left { margin-left: 4cm; margin-right: 3cm; } @page :right { margin-left: 3cm; margin-right: 4cm; }

If different declarations have been given for left and right pages, the user agent must honor these declarations even if the user agent does not transfer the page boxes to left and right sheets (e.g., a printer that only prints single-sided).

Whether the first page of a document is :left or :right depends on the major writing direction of the document and is outside the scope of this document. However, to force a :left or :right first page, authors may insert a page break before the element at the top of the document tree (e.g., the HTML element in HTML).

Note. Adding declarations to the :left or :right pseudo-class does not influence whether the document comes out of the printer double- or single-sided (which is outside the scope of this specification).

Note. Future versions of CSS may include other page pseudo-classes (e.g., :first).

12.3.5 Running headers and footers

It is customary in printed documents to put navigation aids at the top and/or bottom of the page. Often you'll find a page number, the name of the book, and the title of the current chapter there.

CSS defines two areas of the page for holding this kind of information. They are referred to as the :header  and :footer  pseudo-elements, since their default position is above (resp., below) the content of the page. Their content and other properties are defined inside an @page rule:

@page :footer {... footer properties... } @page :header {... header properties... }

Since left and right pages often have different headers and footers, the following defines them individually:

@page :left :footer {...} /* footer of the left page */ @page :right :footer {...} /* footer of the right page */ @page :left :header {...} /* header of the left page */ @page :right :header {...} /* header of the right page */

The cascading rules determine what the values for properties are in case the same property is set on various @page rules. The specificity of @page is 0, every :left, :right, :footer, and :header adds 1 to the specificity.

The :footer and :header areas behave very similar to 'fixed'  elements. The only difference is in their content: in headers and footers the content is limited to one line, and it may vary from page to page, since it can include variables. The page content is the reference box for the header and footer. See section "fixed positioning" for a description of fixed elements.

The initial values for 'top', 'bottom' and 'height' are different for :footer and :header than for normal fixed elements:

  • 'top' in :header has a UA-dependent initial value. A suggested value is -3em.

  • 'bottom' in :footer has a UA-dependent initial value. A suggested value is -3em.

  • 'height' in both :header and :footer has a UA-dependent initial value. A suggested value is 1em.

The suggested values make the header and footer as wide as the page content, and about two lines above (resp., below) it.

The content of the header and footer is specified with the 'content' property. The content is always rendered as a single line. (If the content is too long, the UA should cut it off in some way.) The value is a comma-separated list of 1, 2, or 3 values. Depending on the 'direction' property, the first of these is left- or right-aligned, the second is centered, and the third is right- or left-aligned.

The content is a concatenation of fixed strings and variable parts. The following variable parts are allowed:

[Are these the right names for the variables?]

lower-roman(pageno), upper-roman(pageno), decimal(pageno), lower-alpha(pageno), upper-alpha(pageno)
This expands to the page number, in the specified notation.
lower-roman(pages), upper-roman(pages), decimal(pages), lower-alpha(pages), upper-alpha(pages)
This expands to the total number of pages, in the specified notation.
first(), last(), previous()
can be one of 'title', 'chapter', or 'section'. First() expands to the content of the first element on the page that has a 'running-head:' property. If there is none, 'first()' is the same as 'previous()'. 'Last()' expands to the content of the last element on the page with a 'running-head: property. If there is none, 'last' is the same as 'previous'. 'Previous()' expands to the contents of the last element with 'running-head:' on all pages before this one. If there is none, the result is the empty string.
url
This expands to the URL of the document (not of the style sheet).
date
This expands to the current date, in the user's locale and format.

The "contents" is the text content of the element and all its children, excluding the content of elements that have 'display:none'.

This example creates two running headers, the one on the left page has a page number on the left, and the content of the first element marked as 'chapter' on the right. The right header has the content of the last element marked as 'section' on the left and the page number on the right. Both headers are in 10pt small-caps.

@page :left: header { content: "Page " decimal(pageno), , first(chapter); font-variant: small-caps } @page :right :header { content: last(section), , "Page " decimal(pageno); font-variant: small-caps }

12.3.6 Marking elements for the running headers & footers

To put a copy of the content of an element in the header or footer, the element must be marked. The property 'running-head' is used for that.

'running-head'

Property name:'running-head' 
Value:none | title | chapter | section
Initial:none
Applies to:all elements
Inherited:no
Percentage values:N/A
The value 'none' means that the element is not marked. 'Title', 'chapter' and 'section' say that the element is marked as a title, chapter or section, resp. and that the content can be used in the running header or footer.

This style sheet marks H2 elements as 'chapter' and DT elements as 'section'. This can be used, e.g., in combination with the running headers of the previous example.

H2 {running-head: chapter} DT {running-head: section}

12.3.7 Content outside the page box

When formatting content in the page model, some content may end up outside the page box. For example, an element with 'white-space: pre' may be wider than the page box. Also, when elements are positioned outside the flow model, they may end up in inconvenient locations. For example, images may be placed on the edge of the page box or 100,000 inches below the page box.

A specification for the exact formatting of such elements lies outside the scope of this document. However, we recommend that authors and user agents observe the following general principles concerning content outside the page box:

  • Content should be formatted slightly beyond the page box to allow pages to "bleed".
  • User agents should avoid printing large numbers of blank pages to honor positioning of elements. Note, however, that printing small numbers of blank pages may be necessary to honor the 'left' and 'right' values for 'page-break-before' and 'page-break-after'.
  • Authors should not position elements in inconvenient locations as a means to avoid printing them. Authors should use the 'display' or 'visibility' properties for this purpose.
  • User agents may handle elements positioned outside the page box in several ways, including discarding them or printing them at the end of the document.

12.4 Cascading in the page context

Declarations in the page context cascade just like normal CSS2 declarations.

Consider the following example:

@page { margin-left: 3cm; } @page :left { margin-left: 4cm; }

Due to the higher specificity of the pseudo-class selector (see the section on cascading order for details), the left margin on left pages will be '4cm' and all other pages (i.e., the right pages) will have a left margin of '3cm'.


previous   next   contents   index

Мы с ним какое-то время переписывались, - как бы невзначай сказал Хейл.  - С Танкадо. Ты знала об. Сьюзан посмотрела на него, стараясь не показать свое изумление.

0 thoughts on “Fixed Header And Footer Examples For Essays

Leave a Reply

Your email address will not be published. Required fields are marked *