FFFF csswg-drafts/css2/generate.src at e5bd6297cee7cd476dbf2e1dc8a3b526ff12ac27 · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
1096 lines (881 loc) · 39 KB

File metadata and controls

1096 lines (881 loc) · 39 KB
<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><a name="quotes-insert">Inserting quotes</a> with the <span
class="propinst-content">'content'</span> 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
<span class="propinst-content">'content'</span> property. Each
occurrence of 'open-quote' or 'close-quote' is replaced by one of the
strings from the value of <span
class="propinst-quotes">'quotes'</span>, 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>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>Automatic <span class="index-def" title="counters"><a
name="counters">counters</a></span> and numbering</h2>
<p>Automatic numbering in CSS&nbsp;2 is controlled with two properties,
<span class="propinst-counter-increment">'counter-increment'</span>
and <span class="propinst-counter-reset">'counter-reset'</span>. The
counters defined by these properties are used with the counter() and
counters() functions of the the <span
class="propinst-content">'content'</span> property.
<!-- #include src=properties/counter-reset.srb -->
<!-- #include src=properties/counter-increment.srb -->
<p>The <span
class="propinst-counter-increment">'counter-increment'</span> 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 <span class="propinst-counter-reset">'counter-reset'</span>
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>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
<span class="propinst-content">'content'</span> 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
<span class="propinst-counter-reset">'counter-reset'</span> and <span
class="propinst-counter-increment">'counter-increment'</span>
properties, each reset/increment of the counter is processed in the order
specified.
<div class="example">
<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 <span class="propinst-counter-reset">'counter-reset'</span>
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 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>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 <span class="index-def" title="scope"><dfn>scope</dfn></span>
of a counter starts at the first element in the document that has a
<span class="propinst-counter-reset">'counter-reset'</span> 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 <span
class="propinst-counter-increment">'counter-increment'</span> or <span
class="propinst-content">'content'</span> on an element or
pseudo-element refers to a counter that is not in the scope of any
<span class="propinst-counter-reset">'counter-reset'</span>,
implementations should behave as though a <span
class="propinst-counter-reset">'counter-reset'</span> 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>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&nbsp;2&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>
<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><a name="counter-styles">Counter styles</a></h3>
<p>By default, counters are formatted with decimal numbers, but all the
styles available for the <span
class="propinst-list-style-type">'list-style-type'</span> 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;<span class="propinst-list-style-type">'list-style-type'</span>&gt;)
</pre>
<p>All the styles are allowed, including 'disc', 'circle', 'square',
and 'none'.
<div class="example"><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><a name="undisplayed-counters">Counters in elements with 'display: none'</a></h3>
<p>An element that is not displayed (<span
class="propinst-display">'display'</span> 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>Pseudo-elements that are not generated also cannot increment or
reset a counter.
<div class="example">
<p>For example, the following does not increment 'heading':
<pre>
h1::before {
content: normal;
counter-increment: heading;
}
</pre>
</div>
<p>Elements with <span class="propinst-visibility">'visibility'</span>
set to 'hidden', on the other hand, <em>do</em> increment counters.
<h2><a name="lists">Lists</a></h2>
<P>CSS&nbsp;2 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 <span class="index-def" title="list properties"><dfn>list
properties</dfn></span> 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><a name="list-style">Lists:</a> 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</h3>
<!-- #include src=properties/list-style-type.srb -->
<P> This property specifies appearance of the list item marker if
<span class="propinst-list-style-image">'list-style-image'</span> 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).
<!-- should this be included -->
<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 does not define how the list numbering is reset and
incremented. This is expected to be defined in the CSS List Module
[[CSS3LIST]].
<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>
<!-- #include src=properties/list-style-image.srb -->
<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 <span
class="propinst-list-style-type">'list-style-type'</span> 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.
<li>Otherwise, if the image has an intrinsic ratio and either an
intrinsic width or an intrinsic height, the used width/height is the
same as the provided intrinsic width/height, and the used value of the
missing dimension is calculated from the provided dimension and the
ratio.
<li>Otherwise, if the image has an intrinsic ratio, the used width is
1em and the used height is calculated from this width and the
intrinsic ratio. If this would produce a height larger than 1em, then
the used height is instead set to 1em and the used width is calculated
from this height and the intrinsic ratio.
<li>Otherwise, the image's used width is its intrinsic width if it has
one, or else 1em. The image's used height is its intrinsic height if
it has one, or else 1em.
</ol>
<div class="example"><P>
The following example sets the marker at the beginning of each list
item to be the image "ellipse.png".
<PRE>
ul { list-style-image: url("http://png.com/ellipse.png") }
</PRE>
</div>
<!-- #include src=properties/list-style-position.srb -->
<P> This property specifies the position of the marker box with
respect to the
principal block box. Values have the following meanings:</p>
<dl>
<dt><strong>outside</strong>
<dd>The marker box is outside the principal block box. <!--86-->The
position of the list-item marker adjacent to floats is undefined in
CSS&nbsp;2.<!--/86--> CSS&nbsp;2 does not specify the precise
location of the marker box <!--191-->or its position in the painting
order<!--/191-->, but does
require that for list items whose 'direction' property is 'ltr' the
marker box be on the left side of the content and for elements whose
'direction' property is 'rtl' the marker box be on the right side of
the content.
The marker box is fixed with respect to the principal block box's
border and does not scroll with the principal block box's content.
<!--telcon 2010-11-24-->In CSS&nbsp;2, a UA may hide the marker if
the element's <span class=propinst-overflow>'overflow'</span> is other
than 'visible'. (This is expected to change in the future.)<!--/telcon
2010-11-24-->
The size or contents of the marker box may affect the height of the
principal block box and/or the height of its first line box, and in
some cases may cause the creation of a new line box. <span
class=note><strong>Note:</strong> This interaction may be more
precisely defined in a future level of CSS.</span>
<dt><strong>inside</strong>
<dd>The marker box is placed as the first inline box in the principal
block box, before the element's content and before any :before
pseudo-elements. CSS&nbsp;2 does not specify
the precise location of the marker box.
</dl>
<div class="html-example"><P>
For example:
<PRE>
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;Comparison of inside/outside position&lt;/TITLE&gt;
&lt;STYLE type="text/css"&gt;
ul { list-style: outside }
ul.compact { list-style: inside }
&lt;/STYLE&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;UL&gt;
&lt;LI&gt;first list item comes first
&lt;LI&gt;second list item comes second
&lt;/UL&gt;
&lt;UL class="compact"&gt;
&lt;LI&gt;first list item comes first
&lt;LI&gt;second list item comes second
&lt;/UL&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</PRE>
<P> The above example may be formatted as:</P>
<div class="figure">
<P><img src="./images/list-inout.png" alt="Difference between inside
and outside list style position"></p>
</div>
<P>In right-to-left text, the markers would have been on the right
side of the box.
</div>
<!-- #include src=properties/list-style.srb -->
<P> The <span class="propinst-list-style">'list-style'</span> property
is a shorthand notation for setting the three properties <span
class="propinst-list-style-type">'list-style-type'</span>, <span
class="propinst-list-style-image">'list-style-image'</span>, and <span
class="propinst-list-style-position">'list-style-position'</span> at
the same place in the style sheet.
<div class="example"><P>
<PRE>
ul { list-style: upper-roman inside } /* Any "ul" element */
ul > li > ul { list-style: circle outside } /* Any "ul" child
of an "li" child
of a "ul" element */
</PRE>
</div>
<P>Although authors may specify <span
class="propinst-list-style">'list-style'</span> information directly
on list item elements (e.g., "li" in HTML), they should do so with
care. The following rules look similar, but the first declares a <a
href="./selector.html#descendant-selectors">descendant selector</a>
and the second a (more specific) <a
href="./selector.html#child-selectors">child
selector.</a>
<PRE class="example">
ol.alpha li { list-style: lower-alpha } /* Any "li" descendant of an "ol" */
ol.alpha > li { list-style: lower-alpha } /* Any "li" child of an "ol" */
</PRE>