8000 csswg-drafts/css3-content/Overview.src.html at 2524722888435909d2cb8462d4eb43a3118686a7 · simonwuelker/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
1328 lines (1058 loc) · 47.5 KB

File metadata and controls

1328 lines (1058 loc) · 47.5 KB
<!DOCTYPE html public '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'> <!--*- Mode: Text; fill-column: 95 -*-->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html">
<meta charset="utf-8">
<title>CSS Generated Content Module Level 3</title>
<!--
FIXME when publishing: copy the current default.css and link to
"default.css" rather than "../default.css"
-->
<link rel="stylesheet" type="text/css" href="../css-module/default.css">
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-ED.css">
</head>
<!-- TODO:
! * Sync with CSS2.1 and GCPM
! * Clean up descriptions and organize into something coherent
! * place 'property' into marked up property elements
! * similarly with '::pseudo' and examples
! * http://lists.w3.org/Archives/Member/w3c-css-wg/2003JanMar/0170.html
! * string-set and co
! * need to increment the footnote, endnote and section-note counters
! * cross references, as in http://www.w3.org/Style/Group/2001/MO-css3-page-20010205
! * date() and time()
! * drop nesting
!
!-->
<body>
<div class="head">
<!--logo-->
<h1>CSS Generated Content Module Level 3</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
<dl>
<dt>This version:</dt>
<dd><a href="http://dev.w3.org/csswg/css3-content/">http://dev.w3.org/csswg/css3-content/</a></dd>
<!-- <dd><a
href="[YEAR]/[STATUS]-[SHORTNAME]-[CDATE]">[YEAR]/[STATUS]-[SHORTNAME]-[CDATE]</a></dd> -->
<dt>Latest version:</dt>
<dd><a
href="http://www.w3.org/TR/css3-content/">http://www.w3.org/TR/css3-content/</a></dd>
<dt>Previous versions:</dt>
<dd><a href="http://www.w3.org/TR/2003/WD-css3-content-20030514/">http://www.w3.org/TR/2003/WD-css3-content-20030514/</a></dd>
<dt>Editors:</dt>
<dd><a href="mailto:howcome@opera.com">Håkon Wium Lie</a>, Opera Software
<dd><a href="http://fantasai.inkedblade.net/contact">Elika J. Etemad</a>, W3C Invited Expert
<dd><a href="mailto:ian@hixie.ch">Ian Hickson</a></dd>, Opera Software
</dl>
<!--copyright-->
<hr title="Separator for header">
</div>
<details open class='obsolete'>
<summary>Obsoletion Notice</summary>
<p>This specification is not being actively maintained, and should not be used as a guide for implementations. It may be revived in the future, but for now should be considered obsolete. <br>If you have questions or comments on this specification, please send an email to the CSS Working Group's mailing list at <a href="mailto:www-style@w3.org">www-style@w3.org</a>. (Before sending mail for the first time, you have to subscribe at <a href="http://lists.w3.org/Archives/Public/www-style/">http://lists.w3.org/Archives/Public/www-style/</a>.)</p>
</details>
<h2 class="no-num no-toc" id="abstract">Abstract</h2>
<p>This CSS3 Module describes how to insert and move content around a
document, in order to create footnotes, running headers, and other
generated content effects.</p>
<h2 class="no-num" id="status">Status of this document</h2>
<!--status-->
<h2 class="no-num no-toc" id="contents">Table of contents</h2>
<!--toc-->
<h2>Introduction</h2>
<p>In some cases, authors may want user agents to render content that
does not come from the document tree. One familiar example of this is
numbered headings; the author does not want to mark the numbers up
explicitly, he or she wants the user agent to generate them
automatically. Counters and markers are used to achieve these
effects.</p>
<pre>
INSERT EXAMPLE HERE
</pre>
<p>Similarly, authors may want the user agent to insert the word
"Figure" before the caption of a figure, or "Chapter 7" on a line
before the seventh chapter title.</p>
<pre>
figure > caption::before { content: "Figure: "; }
chapter:nth-child(7) > title::before { content: "Chapter 7\A"; }
</pre>
<p>The last example could also be written in a more generic way using
counters:</p>
<pre>
chapter { counter-increment: chapter; }
chapter > title::before { content: "Chapter " counter(chapter) "\A"; }
</pre>
<p>Another common effect is replacing elements with images or other
multimedia content. Since not all user agents support all multimedia
formats, fallbacks may have to be provided.</p>
<pre>
/* Replace &lt;logo&gt; elements with the site's logo, using a format
* supported by the UA */
logo { content: url(logo.mov), url(logo.mng), url(logo.png), none; }
/* Replace &lt;figure&gt; elements with the referenced document, or,
* failing that, with either the contents of the alt attribute or the
* contents of the element itself if there is no alt attribute */
figure[alt] { content: attr(href, url), attr(alt); }
figure:not([alt]) { content: attr(href, url), contents; }
</pre>
<p>Another effect commonly requested by authors is that of line
numbering. This module introduces the '::line-marker' pseudo-element
that is attached to the front of every line box, which can be used for
this purpose.</p>
<pre>
pre { counter-reset: line; }
pre::line-marker { counter-increment: line; content: counter(line) "."; }
</pre>
<p>This pseudo-element can also be used to simulate the indentation
style found in e-mail communication:</p>
<pre>
blockquote { margin: 0; padding: 0 0 0 2em; } <!-- replace 'em' with 'ch' XXX -->
blockquote > blockquote { margin-left: -1em; }
blockquote::line-marker { width: 2em; text-align: left; content: ">"; }
</pre>
<p>Generated content based on the <code>cite</code> and
<code>datetime</code> attributes can create introductions or citations
on the fly as well.</p>
<!--=======================================================================-->
<h2>Terminology</h2>
<p>This module introduces several pseudo-elements and allows them to nest in certain predefined
ways. In order to explain the relationships between these nested pseudo-elements, three new
terms have been coined.</p>
<dl>
<dt><dfn>superior parent</dfn></dt>
<dd>
A pseudo-element's superior parent is the element
to which it is associated. e.g. the superior parent of the
pseudo-element matched by '::before' is the element to which
it is attached. Note that an element never has a superior parent,
and a pseudo-element always has exactly one. This term is
sometimes shortened to "superior".
</dd>
</dl>
<h2>Pseudo-elements</h2>
<p>At the heart of generated content lies pseudo-elements.
Pseudo-elements create abstractions about the document tree beyond
those specified by the document language. For instance, document
languages do not offer mechanisms to access the first letter or first
line of an element's content. CSS pseudo-elements allow style sheet
designers to refer to this otherwise inaccessible information.
Pseudo-elements also provide style sheet designers a way to assign
style to content that does not exist in the source document.
Pseudo elements are defined in the [[SELECTORS]] specification.</p>
<h3>Inserting content into an element: the '::before' and '::after'
pseudo-elements</h3>
<p>The '::before' and '::after' pseudo-elements are used to insert
content immediately before and immediately after the content of an
element (or other pseudo-element). The 'content' propety is used to
specify the content to insert.</p>
<div class="example"> <p>For example, the following rule replaces the
content of <code>&lt;abbr&gt;</code> elements with the contents of the
element's <code>title</code> attribute:</p>
<pre>
abbr { content: attr(title); }
</pre>
<p>The following rule inserts the string "Note: " before the content
of every P element whose "class" attribute has the value "note":</p>
<pre>
P.note:before { content: "Note: " }
</pre>
</div>
<p>The formatting objects (e.g., boxes) generated by an element include
generated content. So, for example, changing the above style sheet
to:</p>
<pre class="example">
P.note:before { content: "Note: " }
P.note { border: solid green }
</pre>
<p>...would cause a solid green border to be rendered around the entire
paragraph, including the initial string.</p>
<p>The '::before' and '::after' pseudo-elements inherit any
inheritable properties from their superior parent.</p>
<p>For a '::before' or '::after' pseudo-element to be generated,
the pseudo-element must not have its 'content' property set to
'inhibit' or its 'display' property set to 'none'. Note that for
'::before' and '::after' pseudo-elements, the initial value of
'content' computes to 'inhibit'.</p>
<p>Using a '::before' pseudo-element in the context of the anonymous table elements works
exactly as if an actual element had been introduced. For example:</p>
<pre>
.example::before { content: "D" }
</pre>
<pre>
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;C&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="example"&gt;
&lt;td&gt;E&lt;/td&gt; &lt;td&gt;F&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</pre>
<p>An anonymous table cell box is generated around the '::before' content in this case,
resulting in a 3&times;2 table.</p>
<h3>Block markers: The '::marker' pseudo-element</h3>
<p>For a '::marker' pseudo-element to be generated, its superior
parent must have a computed 'display' value of 'list-item'.</p>
<p>For further details on the rendering model for list markers, see
the CSS3 Lists module.</p>
<!--=======================================================================-->
<h3>Line markers: The '::line-marker' pseudo-element</h3>
<p>The '::line-marker' pseudo-element is positioned in exactly the
same way as the '::marker' pseudo-element, but appears on every line,
not just the first.</p>
<p>Line boxes are responsible for generating '::line-marker'
pseudo-elements. For each line, one such marker is created for every
block ancestor in the current block formatting context. [!CSS21]
In addition, for the '::line-marker' pseudo-element to be created,
its 'content' property must have a computed value other than 'none'
or 'inhibit'.</p>
<!-- XXX need examples. Also, show overlap of nested blocks' ::marker,
::line-marker, etc. -->
<!--=======================================================================-->
<h2><a name="quotes-specify">Specifying quotes</a> with the <span
class="propinst-quotes">'quotes'</span> property</h2>
<table class="propdef">
<tbody>
<tr>
<th>Name:</th>
<td><dfn>quotes</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td>foo | bar</td>
</tr>
<tr>
<th>Initial:</th>
<td>text</td>
</tr>
<tr>
<th>Applies To:</th>
<td>all elements</td>
</tr>
<tr>
<th>Inherited:</th>
<td>no</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed&nbsp;value:</th>
<td>specified value</td>
</tr>
</tbody>
</table>
<p>This property specifies quotation marks for any number of embedded
quotations. Values have the following meanings:</p>
<dl>
<dt><dfn>none</dfn></dt>
<dd>The 'open-quote' and 'close-quote' values of the 'content' property produce no quotations marks, as if they were
'no-open-quote' and 'no-close-quote' respectively.</dd>
<dt>[ &lt;string&gt; &lt;string&gt; ]+</dt>
<dd>Values for the 'open-quote' and 'close-quote' values of the 'content' property are taken from this list of pairs of
quotation marks (opening and closing). The first (leftmost) pair represents the outermost level of quotation, the second
pair the first level of embedding, etc. The user agent must apply the appropriate pair of quotation marks according to
the level of embedding.</dd>
</dl>
<div class="example">
<p>For example, applying the following style sheet:</p>
<pre>
/* Specify pairs of quotes for two levels in two languages */
:lang(en) > q { quotes: '"' '"' "'" "'" }
:lang(no) > q { quotes: "+" ";" "&lt;" "&gt;" }
/* Insert quotes before and after Q element content */
q::before { content: open-quote }
q::after { content: close-quote }
</pre>
<p>to the following HTML fragment:</p>
<pre class="html-example">
&lt;HTML lang="en"&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;Quotes&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;P&gt;&lt;Q&gt;Quote me!&lt;/Q&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</pre>
<p>would allow a user agent to produce:</p>
<pre class="ascii-art">
"Quote me!"
</pre>
<p>while this HTML fragment:</p>
<pre class="html-example">
&lt;HTML lang="no"&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;Quotes&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;P&gt;&lt;Q&gt;Tr&oslash;ndere gr&aring;ter n&aring;r &lt;Q&gt;Vinsjan p&aring; kaia&lt;/Q&gt; blir deklamert.&lt;/Q&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</pre>
<p>would produce:</p>
<pre class="ascii-art">
+Tr&oslash;ndere gr&aring;ter n&aring;r &lt;Vinsjan p&aring; kaia&gt; blir deklamert.;
</pre>
</div>
<div class="note">
<p><em>Note.</em> While the quotation marks specified by 'quotes' in the previous examples are conveniently located on
computer keyboards, high quality typesetting would require different ISO 10646 characters. The following informative
table lists some of the ISO 10646 quotation mark characters:</p>
<table>
<tr><th colspan="2">Codepoint<th>Description
<tr><td>&#x0022;<td>U+0022<td>QUOTATION MARK (the ASCII double quotation mark)
<tr><td>&#x0027;<td>U+0027<td>APOSTROPHE (the ASCII single quotation mark)
<tr><td>&#x2039;<td>U+2039<td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK
<tr><td>&#x203A;<td>U+203A<td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
<tr><td>&#x00AB;<td>U+00AB<td>LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
<tr><td>&#x00BB;<td>U+00BB<td>RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
<tr><td>&#x2018;<td>U+2018<td>LEFT SINGLE QUOTATION MARK (single high-6)
<tr><td>&#x2019;<td>U+2019<td>RIGHT SINGLE QUOTATION MARK (single high-9)
<tr><td>&#x201C;<td>U+201C<td>LEFT DOUBLE QUOTATION MARK (double high-6)
<tr><td>&#x201D;<td>U+201D<td>RIGHT DOUBLE QUOTATION MARK (double high-9)
<tr><td>&#x201E;<td>U+201E<td>DOUBLE LOW-9 QUOTATION MARK (double low-9)
</table>
</div>
<h3>Inserting quotes with the 'content' property</h3>
<p>Quotation marks are inserted in appropriate places in a document with the 'open-quote' and 'close-quote' values of
the 'content' property. Each occurrence of 'open-quote' or 'close-quote' is replaced by one of the strings from the
value of 'quotes', based on the depth of nesting.</p>
<p>'Open-quote' refers to the first of a pair of quotes, 'close-quote' refers to the second. Which pair of quotes is
used depends on the nesting level of quotes: the number of occurrences of 'open-quote' in all generated text before the
current occurrence, minus the number of occurrences of 'close-quote'. If the depth is 0, the first pair is used, if the
depth is 1, the second pair is used, etc. If the depth is greater than the number of pairs, the last pair is
repeated.</p>
<p>Note that this quoting depth is independent of the nesting of the source document or the formatting structure.</p>
<p>Some typographic styles require open quotation marks to be repeated before every paragraph of a quote spanning
several paragraphs, but only the last paragraph ends with a closing quotation mark. In CSS, this can be achieved by
inserting "phantom" closing quotes. The keyword 'no-close-quote' decrements the quoting level, but does not insert a
quotation mark.</p>
<div class="example">
<p>The following style sheet puts opening quotation marks on every
paragraph in a BLOCKQUOTE, and inserts a single closing quote at the
end:
<pre>
BLOCKQUOTE P:before { content: open-quote }
BLOCKQUOTE P:after { content: no-close-quote }
BLOCKQUOTE P.last:after { content: close-quote }
</pre>
<p>This relies on the last paragraph being marked with a class "last",
since there are no selectors that can match the last child of an
element.
</div>
<p>For symmetry, there is also a <span class="index-def"
title="no-open-quote"><a class="value-def"
name="value-def-no-open-quote">'no-open-quote'</a></span> keyword,
which inserts nothing, but increments the quotation depth by one.
<div class="note"><p>
<em>Note.</em> If a quotation is in a different language than the
surrounding text, it is customary to quote the text with the quote
marks of the language of the surrounding text, not the language of the
quotation itself.
</div>
<div class="example">
<p>For example, French inside English:
<blockquote>
<p>The device of the order of the garter is &#8220;Honi soit qui mal y
pense.&#8221;
</blockquote>
English inside French:
<blockquote>
<p>Il disait: +&nbsp;Il faut mettre l'action en &#8249;&nbsp;fast
forward&nbsp;&#8250;.;
</blockquote>
<p>A style sheet like the following will set the 'quotes' property so
that 'open-quote' and 'close-quote' will work correctly on all elements.
These rules are for documents that contain only English, French, or
both. One rule is needed for every additional language.
Note the use of the child combinator (">") to set
quotes on elements based on the language of the surrounding
text:</p>
<pre>
:lang(fr) > * { quotes: "+" ";" "\2039" "\203A" }
:lang(en) > * { quotes: "\201C" "\201D" "\2018" "\2019" }
</pre>
<p>The quotation marks for English are shown here in a form that most
people will be able to type. If you can type them directly, they will
look like this:
<pre>
:lang(fr) > * { quotes: "+" ";" "&#8249;" "&#8250;" }
:lang(en) > * { quotes: "&#8220;" "&#8221;" "&#8216;" "&#8217;" }
</pre>
</div>
<!--=======================================================================-->
<h2 id="counters">Automatic counters and numbering: the 'counter-increment' and 'counter-reset'
properties</h2>
<p>Automatic numbering in CSS2 is controlled with two properties, 'counter-increment' and
'counter-reset'. The <span class="index-def" title="counters">counters</span> defined by these
properties are used with the 'counter()' and 'counters()' functions of the the 'content'
property.
<table class="propdef">
<tbody>
<tr>
<th>Name:</th>
<td><dfn>counter-increment</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td>[ &lt;identifier&gt; &lt;integer&gt;? ]+ | none</td>
</tr>
<tr>
<th>Initial:</th>
<td>note</td>
</tr>
<tr>
<th>Applies To:</th>
<td>all elements, ::before, ::after, ::alternate, ::marker, ::line-marker, margin areas, @footnote areas, and @page context</td>
</tr>
<tr>
<th>Inherited:</th>
<td>no</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>all</td>
</tr>
<tr>
<th>Computed&nbsp;value:</th>
<td>specified value</td>
</tr>
</tbody>
</table>
<table class="propdef">
<tbody>
<tr>
<th>Name:</th>
<td><dfn>counter-reset</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td>[ &lt;identifier&gt; &lt;integer&gt;? ]+ | none</td>
</tr>
<tr>
<th>Initial:</th>
<td>note</td>
</tr>
<tr>
<th>Applies To:</th>
<td>all elements, ::before, ::after, ::alternate, ::marker, ::line-marker, margin areas, @footnote areas, and @page context</td>
</tr>
<tr>
<th>Inherited:</th>
<td>no</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>all</td>
</tr>
<tr>
<th>Computed&nbsp;value:</th>
<td>specified value</td>
</tr>
</tbody>
</table>
<p>The 'counter-increment' property accepts one or more names of counters (identifiers), each
one optionally followed by an integer. The integer indicates by how much the counter is
incremented for every occurrence of the element. The default increment is 1. Zero and negative
integers are allowed.
<p>The 'counter-reset' property also contains a list of one or more names of counters, each one
optionally followed by an integer. The integer gives the value that the counter is set to on
each occurrence of the element. The default is 0.
<p>If 'counter-increment' refers to a counter that is not in the <a href="#scope">scope (see
below</a>) of any 'counter-reset', the counter is assumed to have been reset to 0 by the root
element.
<div class="example">
<p>This example shows a way to number chapters and sections with
"Chapter 1", "1.1", "1.2", etc.
<pre>
H1:before {
content: "Chapter " counter(chapter) ". ";
counter-increment: chapter; /* Add 1 to chapter */
counter-reset: section; /* Set section to 0 */
}
H2:before {
content: counter(chapter) "." counter(section) " ";
counter-increment: section;
}
</pre>
</div>
<p>If an element or pseudo-element resets or increments a counter and also uses it (in its
'content' property), the counter is used <em>after</em> being reset or incremented.</p>
<p>If an element or pseudo-element both resets and increments a counter, the counter is reset
first and then incremented.</p>
<p>The 'counter-reset' property follows the cascading rules. Thus, due to cascading, the
following style sheet:</p>
<pre class="example">
H1 { counter-reset: section -1 }
H1 { counter-reset: imagenum 99 }
</pre>
<p>will only reset 'imagenum'. To reset both counters, they have to be
specified together:</p>
<pre class="example">
H1 { counter-reset: section -1 imagenum 99 }
</pre>
<h3><a name="scope">Nested counters and scope</a></h3>
<p>Counters are "self-nesting", in the sense that re-using a counter
in a child element automatically creates a new instance of the
counter. This is important for situations like lists in HTML, where
elements can be nested inside themselves to arbitrary depth. It would
be impossible to define uniquely named counters for each level.
<div class="example">
<p>Thus, the following suffices to number nested list items. The
result is very similar to that of setting 'display:list-item' and
'list-style: inside' on the LI element:
<pre>
OL { counter-reset: item }
LI { display: block }
LI:before { content: counter(item) ". "; counter-increment: item }
</pre>
</div>
<p>The self-nesting is based on the principle that every element or pseudo-element that has a
'counter-reset' for a counter X, creates a fresh counter X, the <dfn>scope</dfn> of which is
the element or pseudo-element, its following siblings, and all the descendants of the element
or pseudo-element and its following siblings.</p>
<p>In the example above, an OL will create a counter, and all children
of the OL will refer to that counter.
<div class="html-example">
<p>If we denote by item[<var>n</var>] the <var>n</var><sup>th</sup> instance of the "item" counter, and by "(" and ")"
the beginning and end of a scope, then the following HTML fragment will use the indicated counters. (We assume the style
sheet as given in the example above).
<pre>
&lt;OL&gt; &lt;!-- (set item[0] to 0 --&gt;
&lt;LI&gt;item &lt;!-- increment item[0] (= 1) --&gt;
&lt;LI&gt;item &lt;!-- increment item[0] (= 2) --&gt;
&lt;OL&gt; &lt;!-- (set item[1] to 0 --&gt;
&lt;LI&gt;item &lt;!-- increment item[1] (= 1) --&gt;
&lt;LI&gt;item &lt;!-- increment item[1] (= 2) --&gt;
&lt;LI&gt;item &lt;!-- increment item[1] (= 3) --&gt;
&lt;OL&gt; &lt;!-- (set item[2] to 0 --&gt;
&lt;LI&gt;item &lt;!-- increment item[2] (= 1) --&gt;
&lt;/OL&gt; &lt;!-- ) --&gt;
&lt;OL&gt; &lt;!-- (set item[3] to 0 --&gt;
< 6178 /div>
&lt;LI&gt; &lt;!-- increment item[3] (= 1) --&gt;
&lt;/OL&gt; &lt;!-- ) --&gt;
&lt;LI&gt;item &lt;!-- increment item[0] (= 3) --&gt;
&lt;LI&gt;item &lt;!-- increment item[0] (= 4) --&gt;
&lt;/OL&gt; &lt;!-- ) --&gt;
&lt;OL&gt; &lt;!-- (reset item[4] to 0 --&gt;
&lt;LI&gt;item &lt;!-- increment item[4] (= 1) --&gt;
&lt;LI&gt;item &lt;!-- increment item[4] (= 2) --&gt;
&lt;/OL&gt; &lt;!-- ) --&gt;
</pre>
</div>
<p>The 'counters()' function generates a string composed of
the values of all counters with the same name, separated by a given string.
<div class="example"><p>
<p>The following style sheet numbers nested list items
as "1", "1.1", "1.1.1", etc.
<pre>
OL { counter-reset: item }
LI { display: block }
LI:before { content: counters(item, "."); counter-increment: item }
</pre>
</div>
<p class=issue>The above counters() example would be terribly wrong
for the above above example since the last list is number 4. The
examples need to reset on the :before pseudo-element for it to work
right)</p>
<h3><a name="counter-styles">Counter styles</a></h3>
<p>By default, counters are formatted with decimal numbers, but all the
styles available for the 'list-style-type' property are
also available for counters. The notation is:</p>
<pre>
counter(<var>name</var>)
</pre>
<p>for the default style, or:</p>
<pre>
counter(<var>name</var>, &lt;'list-style-type'&gt;)
</pre>
<p>All the styles are allowed, including the glyph types such as 'disc', 'circle', and 'square'.
The 'none' value is also allowed, and causes the counter to generate nothing.
<div class="example">
<pre>
H1:before { content: counter(chno, upper-latin) ". " }
H2:before { content: counter(section, upper-roman) " - " }
BLOCKQUOTE:after { content: " [" counter(bq, hebrew) "]" }
DIV.note:before { content: counter(notecntr, disc) " " }
P:before { content: counter(p, none) } /* inserts nothing */
</pre>
</div>
<h3>Counters in elements with 'display: none'</h3>
<p>An element that is not displayed ('display' set to 'none') cannot increment or reset a counter.
<div class="example">
<p>For example, with the following style sheet,
H2s with class "secret" do not increment 'count2'.
<pre>
H2.secret {counter-increment: count2; display: none}
</pre>
</div>
<p>Elements with <span class="propinst-visibility">'visibility'</span>
set to 'hidden', on the other hand, <em>do</em> increment counters.</p>
<h3>Reserved Counter Names</h3>
<p>The 'list-item', 'section-note', 'endnote', and 'footnote' counters
are not reserved. They are ordinary counters that happen to be
incremented and used by other properties as well as the counter
properties.</p>
<p>The 'total-pages' counter, however, is reserved. Resetting or increasing this counter has no
effect. See the Paged Media module [[!CSS3PAGE]] for more information on this counter.</p>
<!--=======================================================================-->
<h2 id="strings">Named strings</h2>
<p class="issue">MERGE WITH GCPM</p>
<p>CSS3 introduces 'named strings', which are the textual equivalent of counters and which have
a distinct namespace from counters. Named strings follow the same nesting rules as counters.
The 'string-set' property accepts values similar to the 'content' property, including the
extraction of the current value of counters.</p>
<p>Named strings are a convenient way to pull metadata out of the document for insertion into
headers and footers. In HTML, for example, META elements contained in the document HEAD can set
the value of named strings. In conjunction with attribute selectors, this can be a powerful
mechanism:</p>
<pre>
META[author] { string-set: author attr(author); }
HEAD &gt; TITLE { string-set: title contents; }
@page:left {
@top {
text-align: left;
vertical-align: middle;
content: string(title);
}
}
@page:right {
@top {
text-align: right;
vertical-align: middle;
content: string(author);
}
}
</pre>
<p class="issue">This section is missing a property definition.</p> <!-- XXX -->
<p class="issue">This section is missing a definition of the string() function.</p> <!-- XXX -->
<div class="example">
<p>The following example captures the contents of H1 elements, which represent chapter names in
this hypothetical document.</p>
<pre>H1 { string-set: chapter contents; }</pre>
<p>When an H1 element is encountered, the 'chapter' string is set to the element's textual
contents, and the previous value of 'chapter', if any, is overwritten.</p>
</div>
<!--=======================================================================-->
<h3>'@counter-styles'</h3>
<p>This at-rule can be used to change the counter's
default counter style. This is typicially used to change, for example, the footnote style:</p>
<pre>
@counter-styles {
footnote: super-decimal;
}
</pre>
<p>The default list style types for counters is 'decimal' except for the 'footnote' counter
which defaults to 'footnotes'.</p>
<h3 id="page-policy">Determining which counter or string-set value to use: the 'page-policy'
property</h3>
<table class="propdef">
<tr><th>Name:</th><td><dfn>page-policy</dfn></td></tr>
<tr><th>Value:</th><td>start | first | last</td></tr>
<tr><th>Initial:</th><td>start</td></tr>
<tr><th>Applies to:</th><td>@counter and @string blocks</td></tr>
<tr><th>Inherited:</th><td>N/A</td></tr>
<tr><th>Percentages:</th><td>N/A</td></tr>
<tr><th>Media:</th><td>paged</td></tr>
<tr><th>Computed&nbsp;value:</th><td>specified value</td></tr>
</table>
<p>'page-policy' determines which page-based occurance of a given
element is applied to a counter or string value:</p>
<dl>
<dt>start</dt>
<dd>Takes the value of the counter or string at the beginning of the page (before applying
style to the elements of the page, but after applying it to the @page context itself).</dd>
<dt>first</dt>
<dd>Takes the value after the first state change in the counter or string during processing of
the page.</dd>
<dt>last</dt>
<dd>Takes the value following the final state change on the page.</dd>
</dl>
<div class="example">
<p>The following example places the chapter name in the header, specifying that it is the value
of the string at the end of the page. Example:</p>
<pre>
@string chapter { page-policy: last; }
@page {
size: 21.0cm 29.7cm; /* A4 */
@top {
text-align: right;
vertical-align: center;
content: string (chapter);
}
}
</pre>
</div>
<p>To use the chapter name as it was when the processing of the page
started, the designer would specify a 'page-policy' of 'start' instead of
'last'. Designers can also use the value of a string or counter after its first
state change on a page by specifying 'first'.</p>
<!--=======================================================================-->
<h2><a name="content-insert">Inserting and replacing content</a> with
the <span class="propinst-content">'content'</span> property</h2>
<table class="propdef">
<tbody>
<tr>
<th>Name:</th>
<td><dfn>content</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td>[ [ &lt;uri&gt; | icon ] ',' ]* [ normal | none | inhibit | &lt;content-list&gt; ]</td>
</tr>
<tr>
<th>Initial:</th>
<td>normal</td>
</tr>
<tr>
<th>Applies To:</th>
<td>all elements, ::before, ::after, ::alternate, ::marker, ::line-marker, margin areas, and @footnote areas</td>
</tr>
<tr>
<th>Inherited:</th>
<td>no</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>all</td>
</tr>
<tr>
<th>Computed&nbsp;value:</th>
<td>The specified value with each occurrence of 'normal' expanded as per the prose below.</td>
</tr>
</tbody>
</table>
<p>The 'content' property dictates what is rendered inside the element
or pseudo-element. It takes a comma separated list of URIs followed by
a space separated list of tokens. If there are multiple URIs provided,
then each is tried in turn until a value which is both available and
supported is found. The last value is used as a fallback if the others
fail.</p>
<dl>
<dt>&lt;uri&gt;</dt>
<dd><p>For URIs other than URIs in the last comma separated section of the value, as those in
the following example:</p>
<pre>
h1 { content: url(header/mng), url(header/png), none; }
</pre>
<p>...then if the URI is available and the format is supported, then the element or
pseudo-element becomes a replaced element, otherwise, the next item in the comma separated list
is used, if any. In the example above, if &# 7C81 039;header/mng' wasn't in a supported format, then
'header/png' would have been used instead. In the example above, if 'header/png' wasn't
available either, then the &lt;h1&gt; element would be empty, as the last alternative is
'none'.</p>
<p>To make an element fallback on its contents, you have to explicitly give 'contents' as a
fallback:</p>
<pre>content: url(1), url(2), url(3), contents;</pre>
<p>If the URI is part of the last comma separated value in the list, as the second URI in the
following example:</p>
<pre>h1 { content: url(welcome), "Welcome to: " url(logo); }</pre>
<p>...then if the file is available and the format is supported,
then an anonymous replaced inline element is inserted, otherwise
the image is ignored (as if it hadn't been given at all).</p>
<p>When a URI is used as replaced content, it <a href="#replacedContent">affects the
generation</a> of '::before' and '::after' pseudo-elements.</dd>
<dt>icon</dt>
<dd>This value is the same as the '&lt;uri&gt;' value above, but takes
the resource from the 'icon' property. If the 'icon' property has the
value 'none' then this is equivalent to the case where the given URI
is not available.</dd>
<dt><dfn>normal</dfn></dt>
<dd>
<p>For an element, this computes to 'contents'.</p>
<p>For '::alternate', if the superior parent uses the 'footnote',
'endnote', or 'section-note' counter in its 'content' property
then the computed value of 'content' is 'contents', otherwise it
computes to 'inhibit'.</p>
<p>For '::before', '::after', and '::line-marker' this computes to
'inhibit'.</p>
<p>For '::marker', if the superior parent's superior parent uses
'footnote' in its 'content' property then 'normal' computes to the
computed value of the 'list-style-image' property if the
list-style-image is not 'none', otherwise 'counter(footnote,
&lt;list-style-type&gt;) "<var>suffix</var>"' where &lt;list-style-type&gt;
is the computed value of the 'list-style-type' property if that
property is not 'none' and <var>suffix</var> is the suffix appropriate for
that list style type, otherwise 'inhibit'.</p>
<p>For '::marker', if the superior parent's superior parent uses
'endnote' in its 'content' property then 'normal' computes to
the computed value of the 'list-style-image' property if the
list-style-image is not 'none', otherwise 'counter(endnote,
&lt;list-style-type&gt;) "<var>suffix</var>"' where &lt;list-style-type&gt;
is the computed value of the 'list-style-type' property if that
property is not 'none' and <var>suffix</var> is the suffix appropriate for
that list style type, otherwise 'inhibit'.</p>
<p>For '::marker', if the superior parent's superior parent uses
'section-note' in its 'content' property then 'normal' computes
to the computed value of the 'list-style-image' property if the
list-style-image is not 'none', otherwise 'counter(section-note,
&lt;list-style-type&gt;) "<var>suffix</var>"' where &lt;list-style-type&gt;
is the computed value of the 'list-style-type' property if that
property is not 'none' and <var>suffix</var> is the suffix appropriate for
that list style type, otherwise 'inhibit'.</p>
<p>Otherwise, for '::marker', if the computed value of 'display'
for the superior parent is 'list-item' then 'normal' computes to