8000 csswg-drafts/css2/generate.html at 0cf85a28f88caa25b9920a1da943cb7c5834a3aa · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
1265 lines (1036 loc) · 56.4 KB

File metadata and controls

1265 lines (1036 loc) · 56.4 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>Generated content, automatic numbering, and lists</title>
<link rel="stylesheet" href="style/default.css" type="text/css">
<link rel="stylesheet" href="https://www.w3.org/StyleSheets/TR/W3C-REC.css" type="text/css">
<link rel="prev" href="visufx.html">
<link rel="next" href="page.html">
<link rel="contents" href="cover.html#minitoc">
<link rel="CSS-properties" href="propidx.html" title="properties">
<link rel="index" href="indexlist.html" title="index">
<link rel="first" href="cover.html">
</head>
<body>
<div class="navbar">
<p><a href="visufx.html">previous</a> &nbsp;
<a href="page.html">next</a> &nbsp;
<a href="cover.html#minitoc">contents</a> &nbsp;
<a href="propidx.html">properties</a> &nbsp;
<a href="indexlist.html">index</a> &nbsp;
</div>
<hr class="navbar">
<h1>12
<a name="generated-text">Generated</a> <a name="x0"><span class="index-def"
title="generated content">content</span></a>, automatic <a name="x1"><span
class="index-def" title="automatic numbering">numbering</span></a>,
and lists</h1>
<div class="subtoc">
<p><strong>Contents</strong>
<ul class="toc">
<li class="tocline2"><a href="generate.html#before-after-content" class="tocxref">12.1 The <span class="index-def" title=":before|pseudo-elements:::before|before">:before</span> and <span class="index-def" title=":after|pseudo-elements:::after|after">:after</span> pseudo-elements</a>
<li class="tocline2"><a href="generate.html#content" class="tocxref">12.2 The <span class="propinst-content">'content'</span> property</a>
<li class="tocline2"><a href="generate.html#quotes" class="tocxref">12.3 Quotation marks</a>
<ul class="toc">
<li class="tocline3"><a href="generate.html#quotes-specify" class="tocxref">12.3.1 Specifying quotes with the <span class="propinst-quotes">'quotes'</span> property</a>
<li class="tocline3"><a href="generate.html#quotes-insert" class="tocxref">12.3.2 Inserting quotes with the <span class="propinst-content">'content'</span> property</a>
</ul>
<li class="tocline2"><a href="generate.html#counters" class="tocxref">12.4 Automatic <span class="index-def" title="counters">counters</span> and numbering</a>
<ul class="toc">
<li class="tocline3"><a href="generate.html#scope" class="tocxref">12.4.1 Nested counters and scope</a>
<li class="tocline3"><a href="generate.html#counter-styles" class="tocxref">12.4.2 Counter styles</a>
<li class="tocline3"><a href="generate.html#undisplayed-counters" class="tocxref">12.4.3 Counters in elements with 'display: none'</a>
</ul>
<li class="tocline2"><a href="generate.html#lists" class="tocxref">12.5 Lists</a>
<ul class="toc">
<li class="tocline3"><a href="generate.html#list-style" class="tocxref">12.5.1 Lists: the <span class="propinst-list-style-type">'list-style-type'</span>, <span class="propinst-list-style-image">'list-style-image'</span>, <span class="propinst-list-style-position">'list-style-position'</span>, and <span class="propinst-list-style">'list-style'</span> properties</a>
</ul>
</ul>
</div>
<!-- warning -->
<div> <input id=annoying-warning type=checkbox title="hide note"> <label for=annoying-warning>(hide)</label> <div class=annoying-warning> <p><strong>Note:</strong> Several sections of this specification have been updated by other specifications. Please, see <a href="https://www.w3.org/TR/CSS/#css" >"Cascading Style Sheets (CSS) &mdash; The Official Definition"</a> in the latest <cite>CSS Snapshot</cite> for a list of specifications and the sections they replace. <p>The CSS Working Group is also developing <a href="http://www.w3.org/TR/CSS22/" >CSS level&nbsp;2 revision&nbsp;2 (CSS&nbsp;2.2).</a> </div> </div>
<!-- /warning -->
<p>In some cases, authors may want user agents to render content
that does not come from the <a href="conform.html#doctree">document
tree</a>. One familiar example of this is a numbered list; the author
does not want to list the numbers explicitly, he or she wants the
user agent to generate them automatically. Similarly, authors
may want the user agent to insert the word
"Figure" before the caption of a figure, or "Chapter 7" before the
seventh chapter title. For audio or braille in particular, user agents
should be able to insert these strings.
<p>In CSS 2.1, content may be generated by two mechanisms:</p>
<ul>
<li>The <a href="generate.html#propdef-content" class="noxref"><span class="propinst-content">'content'</span></a>
property, in conjunction with the :before and :after pseudo-elements.
<li>Elements with a value of 'list-item'
for the <a href="visuren.html#propdef-display" class="noxref"><span class="propinst-display">'display'</span></a> property.
</ul>
<h2>12.1 <a name="before-after-content">The</a> <a name="x2"><span class="index-def"
title=":before|pseudo-elements:::before|before">:before</span></a> and <a name="x5"><span
class="index-def" title=":after|pseudo-elements:::after|after">:after</span></a>
pseudo-elements</h2>
<p>Authors specify the style and location of generated content with
the :before and :after pseudo-elements. As their names indicate, the
:before and :after pseudo-elements specify the location of content
before and after an element's <a href="conform.html#doctree">document
tree</a> content. The <a href="generate.html#propdef-content" class="noxref"><span class="propinst-content">'content'</span></a>
property, in conjunction with these pseudo-elements, specifies what is
inserted.
<div class=example><P style="display:none">Example(s):</P>
<p>For example, 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>The :before and :after pseudo-elements <a
href="cascade.html#inheritance">inherit</a> any inheritable properties
from the element in the document tree to which they are attached.</p>
<div class=example><P style="display:none">Example(s):</P>
<p>For example, the following rules insert an open quote mark before every
Q element. The color of the quote mark will be red, but the font will
be the same as the font of the rest of the Q element:</p>
<pre>
q:before {
content: open-quote;
color: red
}
</pre>
</div>
<p>In a :before or :after pseudo-element declaration, non-inherited
properties take their <a href="about.html#initial-value">initial
values</a>.</p>
<div class=example><P style="display:none">Example(s):</P>
<p>So, for example, because the initial value of the <a href="visuren.html#propdef-display" class="noxref"><span
class="propinst-display">'display'</span></a> property is 'inline', the
quote in the previous example is inserted as an inline box (i.e.,
on the same line as the element's initial text content).
The next example explicitly sets the
<a href="visuren.html#propdef-display" class="noxref"><span class="propinst-display">'display'</span></a> property to
'block', so that the inserted text becomes a block:</p>
<pre>
body:after {
content: "The End";
display: block;
margin-top: 2em;
text-align: center;
}
</pre>
</div>
<p>The :before and :after pseudo-elements interact with other
boxes as if they were real elements inserted just
inside their associated element.</p>
<div class="example"><P style="display:none">Example(s):</P>
<p>For example, the following document fragment and style sheet:</p>
<pre>
&lt;p> Text &lt;/p> p:before { display: block; content: 'Some'; }
</pre>
<p>...would render in exactly the same way as the following document
fragment and style sheet:</p>
<pre>
&lt;p>&lt;span>Some&lt;/span> Text &lt;/p> span { display: block }
</pre>
<p>Similarly, the following document fragment and style sheet:</p>
<pre>
&lt;h2> Header &lt;/h2> h2:after { display: block; content: 'Thing'; }
</pre>
<p>...would render in exactly the same way as the following document
fragment and style sheet:</p>
<pre>
&lt;h2> Header &lt;span>Thing&lt;/span>&lt;/h2> h2 { display: block; }
span { display: block; }
</pre>
</div>
<div class="note">
<p><strong>Note.</strong> This specification does not fully define the interaction of :before
and :after with replaced elements (such as IMG in HTML). This will
be defined in more detail in a future specification.</p>
</div>
<h2>12.2 <a name="content">The</a> <a href="generate.html#propdef-content" class="noxref"><span
class="propinst-content">'content'</span></a> property</h2>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'content'"><a name="propdef-content" class="propdef-title"><strong>'content'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em>&nbsp;&nbsp;<td>normal | none | [ <a href="syndata.html#value-def-string" class="noxref"><span class="value-inst-string">&lt;string&gt;</span></a> | <a href="syndata.html#value-def-uri" class="noxref"><span class="value-inst-uri">&lt;uri&gt;</span></a> | <a href="syndata.html#value-def-counter" class="noxref"><span class="value-inst-counter">&lt;counter&gt;</span></a> | attr(<a href="syndata.html#value-def-identifier" class="noxref"><span class="value-inst-identifier">&lt;identifier&gt;</span></a>) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em>&nbsp;&nbsp;<td>normal
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>:before and :after pseudo-elements
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>no
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#all-media-group" class="noxref">all</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<td>On elements, always computes to 'normal'. On :before and :after, if
'normal' is specified, computes to 'none'. Otherwise, for URI
values, the absolute URI; for attr() values, the resulting string;
for other keywords, as specified.
</table>
</dl>
</div>
<p>This property is used with the :before and :after pseudo-elements
to generate content in a document. Values have the following
meanings:</p>
<dl>
<dt><a name="x9"><span class="index-inst" title="none"><strong>none</strong></span></a>
<dd>The pseudo-element is not generated.</dd>
<dt><a name="x10"><span class="index-inst" title="normal"><strong>normal</strong></span></a>
<dd>Computes to 'none' for the :before and :after pseudo-elements.</dd>
<dt><span class="index-inst" title="&lt;string&gt;"><a name="x11" href="syndata.html#value-def-string" class="noxref"><span
class="value-inst-string"><strong>&lt;string&gt;</strong></span></a></span>
<dd>Text content
(see the section on <a href="syndata.html#strings">strings</a>).
<dt><span class="index-inst" title="&lt;uri&gt;"><a name="x12" href="syndata.html#value-def-uri" class="noxref"><span
class="value-inst-uri"><strong>&lt;uri&gt;</strong></span></a></span>
<dd>The value is a URI that designates an external resource (such as an image).
If the user agent cannot display the resource it must either leave
it out as if it were not specified or display some indication that
the resource cannot be displayed.
<dt><span class="index-inst" title="&lt;counter&gt;"><a name="x13" href="syndata.html#value-def-counter" class="noxref"><span
class="value-inst-counter"><strong>&lt;counter&gt;</strong></span></a></span>
<dd><a href="syndata.html#counter">Counters</a> may be specified
with two different functions: 'counter()' or 'counters()'.
The former has two forms:
'counter(<var>name</var>)' or 'counter(<var>name</var>,
<var>style</var>)'.
The generated text is the value of the innermost counter of the given
name in scope at this pseudo-element; it is formatted in the indicated
<a href="#counter-styles">style</a> ('decimal' by default). The latter
function also has two forms: 'counters(<var>name</var>,
<var>string</var>)' or 'counters(<var>name</var>, <var>string</var>,
<var>style</var>)'. The generated text is the value of all counters
with the given name in scope at this pseudo-element, from outermost to
innermost separated by the specified string. The counters are rendered
in the indicated <a href="#counter-styles">style</a> ('decimal' by
default). See the section on <a href="#counters">automatic counters
and numbering</a> for more information.
The name must not be 'none', 'inherit' or 'initial'. Such a name
causes the declaration to be ignored.
<dt><span class="index-inst"
title="open-quote"><a name="x14" href="generate.html#value-def-open-quote" class="noxref"><span
class="value-inst-open-quote"><strong>open-quote</strong></span></a></span>
and <span class="index-inst" title="close-quote"><a name="x15" href="generate.html#value-def-close-quote" class="noxref"><span
class="value-inst-close-quote"><strong>close-quote</strong></span></a></span>
<dd>These values are replaced by the appropriate string
from the <a href="generate.html#propdef-quotes" class="noxref"><span class="propinst-quotes"><strong>'quotes'</strong></span></a> property.
<dt><span class="index-inst" title="no-open-quote"><a name="x16" href="generate.html#value-def-no-open-quote" class="noxref"><span
class="value-inst-no-open-quote"><strong>no-open-quote</strong></span></a></span>
and <span class="index-inst" title="no-close-quote"><a name="x17" href="generate.html#value-def-no-close-quote" class="noxref"><span
class="value-inst-no-close-quote"><strong>no-close-quote</strong></span></a></span>
<dd>Introduces no content, but increments (decrements) the level of nesting for quotes.
<dt><a name="x18"><span class="index-def" title="attr()"><strong>attr(X)</strong></span></a>
<dd>This function returns as a string the value of attribute X
for the subject of the selector. The
string is not parsed by the CSS processor. If the subject of the selector
does not have an attribute X, an empty string is returned. The
case-sensitivity of attribute names depends on the document language.
</dl>
<div class="note">
<strong>Note.</strong> In CSS 2.1, it is not possible to refer to
attribute values for other elements than the subject of the selector.
</div>
<P>The <a href="visuren.html#propdef-display" class="noxref"><span class="propinst-display">'display'</span></a> property
controls whether the content is placed in a block or inline box.
<div class="example"><P style="display:none">Example(s):</P><p>The following rule causes the string "Chapter: " to be generated before each H1 element:</p>
<pre>
H1:before {
content: "Chapter: ";
display: inline;
}
</pre>
</div>
<p>Authors may include newlines in the generated content by writing
the "\A" escape sequence in one of the strings after the <a href="generate.html#propdef-content" class="noxref"><span
class="propinst-content">'content'</span></a> property. This inserted line
break is still subject to the <a href="text.html#propdef-white-space" class="noxref"><span
class="propinst-white-space">'white-space'</span></a> property. See <a
href="syndata.html#strings">"Strings"</a> and <a
href="syndata.html#escaped-characters">"Characters and case"</a> for
more information on the "\A" escape sequence.
<div class="example"><P style="display:none">Example(s):</P><P>
<PRE>
h1:before {
display: block;
text-align: center;
white-space: pre;
content: "chapter\A hoofdstuk\A chapitre"
}
</pre>
</div>
<P>Generated content does not alter the document tree. In particular, it
is not fed back to the document language processor (e.g., for
reparsing).
<h2>12.3 <a name="quotes">Quotation marks</a></h2>
<P>In CSS 2.1, authors may specify, in a style-sensitive and
context-dependent manner, how user agents should render quotation
marks. The <a href="generate.html#propdef-quotes" class="noxref"><span class="propinst-quotes">'quotes'</span></a> property
specifies pairs of quotation marks for each level of embedded
quotation. The <a href="generate.html#propdef-content" class="noxref"><span class="propinst-content">'content'</span></a>
property gives access to those quotation marks and causes them to be
inserted before and after a quotation.
<H3>12.3.1 <a name="quotes-specify">Specifying quotes</a> with the <a href="generate.html#propdef-quotes" class="noxref"><span
class="propinst-quotes">'quotes'</span></a> property</H3>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'quotes'"><a name="propdef-quotes" class="propdef-title"><strong>'quotes'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em>&nbsp;&nbsp;<td>[<a href="syndata.html#value-def-string" class="noxref"><span class="value-inst-string">&lt;string&gt;</span></a> <a href="syndata.html#value-def-string" class="noxref"><span class="value-inst-string">&lt;string&gt;</span></a>]+ | none | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em>&nbsp;&nbsp;<td>depends on user agent
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>all elements
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>yes
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<td>as specified
</table>
</dl>
</div>
<P>This property specifies quotation marks for any number of embedded
quotations. Values have the following meanings:</p>
<dl>
<dt><strong>none</strong>
<dd>The 'open-quote' and 'close-quote' values of the
<a href="generate.html#propdef-content" class="noxref"><span class="propinst-content">'content'</span></a> property
produce no quotation marks.
<dt>[<span class="index-inst" title="&lt;string&gt;"><a name="x20" href="syndata.html#value-def-string" class="noxref"><span
class="value-inst-string"><strong>&lt;string&gt;</strong></span></a></span>
&nbsp;<span class="index-inst" title="&lt;string&gt;"><a name="x21" href="syndata.html#value-def-string" class="noxref"><span
class="value-inst-string"><strong>&lt;string&gt;</strong></span></a></span>]+
<dd>Values for the 'open-quote' and 'close-quote' values of the
<a href="generate.html#propdef-content" class="noxref"><span class="propinst-content">'content'</span></a> 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.
</dl>
<div class="example"><P style="display:none">Example(s):</P>
<P>For example, applying the following style sheet:</p>
<PRE class="example">
/* Specify pairs of quotes for two levels in two languages */
q:lang(en) { quotes: '"' '"' "'" "'" }
q:lang(no) { quotes: "«" "»" '"' '"' }
/* 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 "Vinsjan p&aring; kaia" blir deklamert.»
</PRE>
</div>
<div class="note"><P>
<em><strong>Note.</strong>
While the quotation marks specified by <a href="generate.html#propdef-quotes" class="noxref"><span
class="propinst-quotes">'quotes'</span></a> 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:</em></p>
<TABLE border>
<TR><TH>Character</TH><TH>Approximate rendering<TH>ISO 10646 code (hex)<TH>Description
<TR><TD>&#x0022;<TD>"<TD>0022<TD>QUOTATION MARK [the ASCII double quotation mark]
<TR><TD>&#x0027;<TD>'<TD>0027<TD>APOSTROPHE [the ASCII single quotation mark]
<TR><TD>&#x2039;<TD>&lt;<TD>2039<TD>SINGLE LEFT-POINTING ANGLE QUOTATION MARK
<TR><TD>&#x203A;<TD>><TD>203A<TD>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
<TR><TD>&#x00AB;<TD>«<TD>00AB<TD>LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
<TR><TD>&#x00BB;<TD>»<TD>00BB<TD>RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
<TR><TD>&#x2018;<TD>`<TD>2018<TD>LEFT SINGLE QUOTATION MARK [single high-6]
<TR><TD>&#x2019;<TD>'<TD>2019<TD>RIGHT SINGLE QUOTATION MARK [single high-9]
<TR><TD>&#x201C;<TD>``<TD>201C<TD>LEFT DOUBLE QUOTATION MARK [double high-6]
<TR><TD>&#x201D;<TD>''<TD>201D<TD>RIGHT DOUBLE QUOTATION MARK [double high-9]
<TR><TD>&#x201E;<TD>,,<TD>201E<TD>DOUBLE LOW-9 QUOTATION MARK [double low-9]
</TABLE>
</div>
<H3>12.3.2 <a name="quotes-insert">Inserting quotes</a> with the <a href="generate.html#propdef-content" class="noxref"><span
class="propinst-content">'content'</span></a> property</H3>
<p>Quotation marks are inserted in appropriate places in a document
with the <span class="index-def" title="open-quote"><a
class="value-def" name="value-def-open-quote">'open-quote'</a></span>
and <span class="index-def" title="close-quote"><a class="value-def"
name="value-def-close-quote">'close-quote'</a></span> values of the
<a href="generate.html#propdef-content" class="noxref"><span class="propinst-content">'content'</span></a> property. Each
occurrence of 'open-quote' or 'close-quote' is replaced by one of the
strings from the value of <a href="generate.html#propdef-quotes" class="noxref"><span
class="propinst-quotes">'quotes'</span></a>, based on the depth of
nesting.
<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. A 'close-quote'
or 'no-close-quote' that would make the depth negative is in error and is
ignored (at rendering time): the depth stays at 0 and no quote mark is
rendered (although the rest of the 'content' property's value is still
inserted).
<div class="note"><p>
<em><strong>Note.</strong> The quoting depth is independent of the nesting
of the source document or the formatting structure.</em>
</p></div>
<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 <span class="index-def" title="no-close-quote"><a
class="value-def"
name="value-def-no-close-quote">'no-close-quote'</a></span> decrements
the quoting level, but does not insert a quotation mark.
<div class="example"><P style="display:none">Example(s):</P>
<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".
</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.
<h2>12.4 Automatic <span class="index-def" title="counters"><a
name="counters">counters</a></span> and numbering</h2>
<p>Automatic numbering in CSS&nbsp;2.1 is controlled with two properties,
<a href="generate.html#propdef-counter-increment" class="noxref"><span class="propinst-counter-increment">'counter-increment'</span></a>
and <a href="generate.html#propdef-counter-reset" class="noxref"><span class="propinst-counter-reset">'counter-reset'</span></a>. The
counters defined by these properties are used with the counter() and
counters() functions of the the <a href="generate.html#propdef-content" class="noxref"><span
class="propinst-content">'content'</span></a> property.
<div class="propdef">
<dl><dt>
<span class="index-def" title="'counter-reset'"><a name="propdef-counter-reset" class="propdef-title"><strong>'counter-reset'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em>&nbsp;&nbsp;<td>[ <a href="syndata.html#value-def-identifier" class="noxref"><span class="value-inst-identifier">&lt;identifier&gt;</span></a> <a href="syndata.html#value-def-integer" class="noxref"><span class="value-inst-integer">&lt;integer&gt;</span></a>? ]+ | none | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em>&nbsp;&nbsp;<td>none
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>all elements
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>no
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#all-media-group" class="noxref">all</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<td>as specified
</table>
</dl>
</div>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'counter-increment'"><a name="propdef-counter-increment" class="propdef-title"><strong>'counter-increment'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em>&nbsp;&nbsp;<td>[ <a href="syndata.html#value-def-identifier" class="noxref"><span class="value-inst-identifier">&lt;identifier&gt;</span></a> <a href="syndata.html#value-def-integer" class="noxref"><span class="value-inst-integer">&lt;integer&gt;</span></a>? ]+ | none | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em>&nbsp;&nbsp;<td>none
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>all elements
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>no
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#all-media-group" class="noxref">all</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<td>as specified
</table>
</dl>
</div>
<p>The <a href="generate.html#propdef-counter-increment" class="noxref"><span
class="propinst-counter-increment">'counter-increment'</span></a> 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 <a href="generate.html#propdef-counter-reset" class="noxref"><span class="propinst-counter-reset">'counter-reset'</span></a>
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>The keywords 'none', 'inherit' and 'initial' must not be used as
counter names. A value of 'none' on its own means no counters are
reset, resp. incremented. 'Inherit' on its own has its usual meaning
(see <a href="cascade.html#value-def-inherit">6.2.1</a>). 'Initial' is
reserved for future use.
<div class="example"><P style="display:none">Example(s):</P>
<p>This example shows a way to number chapters and sections with
"Chapter 1", "1.1", "1.2", etc.
<pre>
BODY {
counter-reset: chapter; /* Create a chapter counter scope */
}
H1:before {
content: "Chapter " counter(chapter) ". ";
counter-increment: chapter; /* Add 1 to chapter */
}
H1 {
counter-reset: section; /* Set section to 0 */
}
H2:before {
content: counter(chapter) "." counter(section) " ";
counter-increment: section;
}
</pre>
</div>
<p>If an element increments/resets a counter and also uses it (in the
<a href="generate.html#propdef-content" class="noxref"><span class="propinst-content">'content'</span></a> property of its
:before or :after pseudo-element), the counter is used <em>after</em>
being incremented/reset.
<p>If an element both resets and increments a counter, the counter is
reset first and then incremented.
<p>If the same counter is specified more than once in the value of the
<a href="generate.html#propdef-counter-reset" class="noxref"><span class="propinst-counter-reset">'counter-reset'</span></a> and <a href="generate.html#propdef-counter-increment" class="noxref"><span
class="propinst-counter-increment">'counter-increment'</span></a>
properties, each reset/increment of the counter is processed in the order
specified.
<div class="example"><P style="display:none">Example(s):</P>
<p>The following example will reset the 'section' counter to 0:
<pre>
H1 { counter-reset: section 2 section }
</pre>
<p>The following example will increment the 'chapter' counter by 3:
<pre>
H1 { counter-increment: chapter chapter 2 }
</pre>
</div>
<P>The <a href="generate.html#propdef-counter-reset" class="noxref"><span class="propinst-counter-reset">'counter-reset'</span></a>
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>12.4.1 <a name="scope">Nested counters and scope</a></h3>
<p>Counters are "self-nesting", in the sense that resetting a counter
in a descendant element or pseudo-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 style="display:none">Example(s):</P>
<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 <a name="x29"><span class="index-def" title="scope"><dfn>scope</dfn></span></a>
of a counter starts at the first element in the document that has a
<a href="generate.html#propdef-counter-reset" class="noxref"><span class="propinst-counter-reset">'counter-reset'</span></a> for that
counter and includes the element's descendants and its following
siblings with their descendants. However, it does not include any
elements in the scope of a counter with the same name created by a 'counter-reset' on a
later sibling of the element or by a later 'counter-reset' on the same
element.
<p>If <a href="generate.html#propdef-counter-increment" class="noxref"><span
class="propinst-counter-increment">'counter-increment'</span></a> or <a href="generate.html#propdef-content" class="noxref"><span
class="propinst-content">'content'</span></a> on an element or
pseudo-element refers to a counter that is not in the scope of any
<a href="generate.html#propdef-counter-reset" class="noxref"><span class="propinst-counter-reset">'counter-reset'</span></a>,
implementations should behave as though a <a href="generate.html#propdef-counter-reset" class="noxref"><span
class="propinst-counter-reset">'counter-reset'</span></a> had reset the
counter to 0 on that element or pseudo-element.
<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[n] the
n<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> &lt;!-- {item[0]=0 -->
&lt;LI>item&lt;/LI> &lt;!-- item[0]++ (=1) -->
&lt;LI>item &lt;!-- item[0]++ (=2) -->
&lt;OL> &lt;!-- {item[1]=0 -->
&lt;LI>item&lt;/LI> &lt;!-- item[1]++ (=1) -->
&lt;LI>item&lt;/LI> &lt;!-- item[1]++ (=2) -->
&lt;LI>item &lt;!-- item[1]++ (=3) -->
&lt;OL> &lt;!-- {item[2]=0 -->
&lt;LI>item&lt;/LI> &lt;!-- item[2]++ (=1) -->
&lt;/OL> &lt;!-- -->
&lt;OL> &lt;!-- }{item[2]=0 -->
&lt;LI>item&lt;/LI> &lt;!-- item[2]++ (=1) -->
&lt;/OL> &lt;!-- -->
&lt;/LI> &lt;!-- } -->
&lt;LI>item&lt;/LI> &lt;!-- item[1]++ (=4) -->
&lt;/OL> &lt;!-- -->
&lt;/LI> &lt;!-- } -->
&lt;LI>item&lt;/LI> &lt;!-- item[0]++ (=3) -->
&lt;LI>item&lt;/LI> &lt;!-- item[0]++ (=4) -->
&lt;/OL> &lt;!-- -->
&lt;OL> &lt;!-- }{item[0]=0 -->
&lt;LI>item&lt;/LI> &lt;!-- item[0]++ (=1) -->
&lt;LI>item&lt;/LI> &lt;!-- item[0]++ (=2) -->
&lt;/OL> &lt;!-- -->
</pre>
</div>
<div class="example"><P style="display:none">Example(s):</P>
<p>Another example, showing how scope works when counters are used on
elements that are not nested, is the following. This shows how the
style rules given above to number chapters and sections would apply to
the markup given.
<pre>
&lt;!--"chapter" counter|"section" counter -->
&lt;body> &lt;!-- {chapter=0 | -->
&lt;h1>About CSS&lt;/h1> &lt;!-- chapter++ (=1) | {section=0 -->
&lt;h2>CSS 2&lt;/h2> &lt;!-- | section++ (=1) -->
&lt;h2>CSS 2.1&lt;/h2> &lt;!-- | section++ (=2) -->
&lt;h1>Style&lt;/h1> &lt;!-- chapter++ (=2) |}{ section=0 -->
&lt;/body> &lt;!-- | } -->
</pre>
</div>
<p>The 'counters()' function generates a string composed of all of the
counters with the same name that are in scope, separated by a given
string.
<div class="example"><P style="display:none">Example(s):</P><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>
<h3>12.4.2 <a name="counter-styles">Counter styles</a></h3>
<p>By default, counters are formatted with decimal numbers, but all the
styles available for the <a href="generate.html#propdef-list-style-type" class="noxref"><span
class="propinst-list-style-type">'list-style-type'</span></a> 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;<a href="generate.html#propdef-list-style-type" class="noxref"><span class="propinst-list-style-type">'list-style-type'</span></a>&gt;)
</pre>
<p>All the styles are allowed, including 'disc', 'circle', 'square',
and 'none'.
<div class="example"><P style="display:none">Example(s):</P><P>
<pre>
H1:before { content: counter(chno, upper-latin) ". " }
H2:before { content: counter(section, upper-roman) " - " }
BLOCKQUOTE:after { content: " [" counter(bq, lower-greek) "]" }
DIV.note:before { content: counter(notecntr, disc) " " }
P:before { content: counter(p, none) }
</pre>
</div>
<h3>12.4.3 <a name="undisplayed-counters">Counters in elements with 'display: none'</a></h3>
<p>An element that is not displayed (<a href="visuren.html#propdef-display" class="noxref"><span
class="propinst-display">'display'</span></a> set to 'none') cannot
increment or reset a counter.
<div class="example"><P style="display:none">Example(s):</P>
<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>Pseudo-elements that are not generated also cannot increment or
reset a counter.
<div class="example"><P style="display:none">Example(s):</P>
<p>For example, the following does not increment 'heading':
<pre>
h1::before {
content: normal;
counter-increment: heading;
}
</pre>
</div>
<p>Elements with <a href="visufx.html#propdef-visibility" class="noxref"><span class="propinst-visibility">'visibility'</span></a>
set to 'hidden', on the other hand, <em>do</em> increment counters.
<h2>12.5 <a name="lists">Lists</a></h2>
<P>CSS 2.1 offers basic visual formatting of lists. An element with
'display: list-item' generates a <a
href="visuren.html#principal-box">principal block box</a> for the element's
content and, depending on the values of 'list-style-type' and
'list-style-image', possibly also a marker box as a visual indication
that the
element is a list item.
<P>The <a name="x30"><span class="index-def" title="list properties"><dfn>list
properties</dfn></span></a> describe basic visual formatting of lists:
they allow style sheets to specify the marker type (image, glyph, or
number), and the marker position with respect to the principal box
(outside it or within it before content). They do not allow authors to
specify distinct style (colors, fonts, alignment, etc.) for the list
marker or adjust its position with respect to the principal box; these
may be derived from the principal box.
<P>The <a href="colors.html#background-properties">background
properties</a> apply to the principal box only; an 'outside' marker
box is transparent.
<h3>12.5.1 <a name="list-style">Lists:</a> the <a href="generate.html#propdef-list-style-type" class="noxref"><span
class="propinst-list-style-type">'list-style-type'</span></a>, <a href="generate.html#propdef-list-style-image" class="noxref"><span
class="propinst-list-style-image">'list-style-image'</span></a>, <a href="generate.html#propdef-list-style-position" class="noxref"><span
class="propinst-list-style-position">'list-style-position'</span></a>, and
<a href="generate.html#propdef-list-style" class="noxref"><span class="propinst-list-style">'list-style'</span></a> properties</h3>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'list-style-type'"><a name="propdef-list-style-type" class="propdef-title"><strong>'list-style-type'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em>&nbsp;&nbsp;<td>disc | circle | square | decimal | decimal-leading-zero |
lower-roman | upper-roman | lower-greek |
lower-latin | upper-latin | armenian | georgian |
lower-alpha | upper-alpha |
none | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em>&nbsp;&nbsp;<td>disc
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>elements with 'display: list-item'
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>yes
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#visual-media-group" class="noxref">visual</a>
< 619E div>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<td>as specified
</table>
</dl>
</div>
<P> This property specifies appearance of the list item marker if
<a href="generate.html#propdef-list-style-image" class="noxref"><span class="propinst-list-style-image">'list-style-image'</span></a> has
the value 'none' or if the image pointed to by the URI cannot be
displayed. The value 'none' specifies no marker, otherwise there are
three types of marker: glyphs, numbering systems, and alphabetic
systems.
<P>Glyphs are specified with
<strong><span class="index-def" title="disc"><a class="value-def"
name="value-def-disc">disc</a></span></strong>,
<strong><span class="index-def" title="circle"><a class="value-def"
name="value-def-circle">circle</a></span></strong>, and
<strong><span class="index-def" title="square"><a class="value-def"
name="value-def-square">square</a></span></strong>. Their exact
rendering depends on the user agent.
<P>Numbering systems are specified with:</P>
<dl>
<dt><span class="index-def" title="decimal"><a class="value-def" name="value-def-decimal"><strong>decimal</strong></a></span><dd>Decimal numbers, beginning with 1.
<dt><strong><span class="index-def" title="decimal-leading-zero"><a class="value-def" name="value-def-decimal-leading-zero">decimal-leading-zero</a></span></strong>
<dd>Decimal numbers padded by initial zeros (e.g., 01, 02, 03, ..., 98, 99).
<dt><strong><span class="index-def" title="lower-roman"><a class="value-def" name="value-def-lower-roman">lower-roman</a></span></strong>
<dd>Lowercase roman numerals (i, ii, iii, iv, v, etc.).
<dt><strong><span class="index-def" title="upper-roman"><a class="value-def" name="value-def-upper-roman">upper-roman</a></span></strong>
<dd>Uppercase roman numerals (I, II, III, IV, V, etc.).
<dt><strong><span class="index-def" title="georgian"><a class="value-def" name="value-def-georgian">georgian</a></span></strong>
<dd>Traditional Georgian numbering
(an, ban, gan, ..., he, tan, in, in-an, ...).
<dt><strong><span class="index-def" title="armenian"><a class="value-def" name="value-def-armenian">armenian</a></span></strong>
<dd>Traditional uppercase Armenian numbering.
</dl>
<P>Alphabetic systems are specified with:</P>
<dl>
<dt><strong><span class="index-def" title="lower-latin"><a class="value-def" name="value-def-lower-latin">lower-latin</a></span></strong> or <strong>lower-alpha</strong>
<dd>Lowercase ascii letters (a, b, c, ... z).
<dt><strong><span class="index-def" title="upper-latin"><a class="value-def" name="value-def-upper-latin">upper-latin</a></span></strong> or <strong>upper-alpha</strong>
<dd>Uppercase ascii letters (A, B, C, ... Z).
<dt><strong><span class="index-def" title="lower-greek"><a class="value-def" name="value-def-lower-greek">lower-greek</a></span></strong>
<dd>Lowercase classical Greek
alpha, beta, gamma, ... (&#945;, &#946;, &#947;, ...)
</dl>
<P>This specification does not define how alphabetic systems wrap at
the end of the alphabet. For instance, after 26 list items,
'lower-latin' rendering is undefined. Therefore, for long lists, we
recommend that authors specify true numbers.
<p>CSS&nbsp;2.1 does not define how the list numbering is reset and
incremented. This is expected to be defined in the CSS List Module
<a href="refs.html#ref-CSS3LIST" rel="biblioentry" class="noxref"><span class="informref">[CSS3LIST]</span></a>.
<div class="html-example"><P>
For example, the following HTML document:
<PRE>
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;Lowercase latin numbering&lt;/TITLE&gt;
&lt;STYLE type="text/css"&gt;
ol { list-style-type: lower-roman }
&lt;/STYLE&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;OL&gt;
&lt;LI&gt; This is the first item.
&lt;LI&gt; This is the second item.
&lt;LI&gt; This is the third item.
&lt;/OL&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</PRE>
<P>might produce something like this:
<PRE>
i This is the first item.
ii This is the second item.
iii This is the third item.
</PRE>
<P>The list marker alignment (here, right justified) depends on the user agent.
</div>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'list-style-image'"><a name="propdef-list-style-image" class="propdef-title"><strong>'list-style-image'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em>&nbsp;&nbsp;<td><a href="syndata.html#value-def-uri" class="noxref"><span class="value-inst-uri">&lt;uri&gt;</span></a> | none | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a>
<tr valign=baseline><td><em>Initial:</em>&nbsp;&nbsp;<td>none
<tr valign=baseline><td><em>Applies to:</em>&nbsp;&nbsp;<td>elements with 'display: list-item'
<tr valign=baseline><td><em>Inherited:</em>&nbsp;&nbsp;<td>yes
<tr valign=baseline><td><em>Percentages:</em>&nbsp;&nbsp;<td>N/A
<tr valign=baseline><td><em>Media:</em>&nbsp;&nbsp;<td><a href="media.html#visual-media-group" class="noxref">visual</a>
<tr valign=baseline><td><em>Computed&nbsp;value:</em>&nbsp;&nbsp;<td>absolute URI or 'none'
</table>
</dl>
</div>
<P> This property sets the image that will be used as the list item
marker. When the image is available, it will replace the marker set
with the <a href="generate.html#propdef-list-style-type" class="noxref"><span
class="propinst-list-style-type">'list-style-type'</span></a> marker.
<p>The size of the image is calculated from the following rules:
<ol>
<li>If the image has a intrinsic width and height, the used width and
height are the intrinsic width and height.