The mark-up of the CSS specifications

The CSS level 2 specification and the various modules of CSS level 3 have specific mark-up beyond HTML. That mark-up allows the different kinds of information (names of properties, informative notes, examples, etc.) to be styled appropriately, but above all it allows various automated tools to read the specifications. Those tools can make an index of all properties, extract a machine-readable grammar, check all examples, etc. The following sections contain the details.

The origins of the mark-up conventions

The mark-up of CSS2 and CSS3 are not the same. The CSS3 mark-up is several years younger and is an evolution of the CSS2 one. It is both more compact and richer in semantics.

The mark-up in the published texts of CSS is also not exactly the same as the mark-up that the authors used when writing the text. The latter has abbreviations that are expanded automatically before a document is published. For example, the authors almost never create links. Instead, they include a tag or a special character that indicates the role of a word (a property name, a technical term, a bibliographic reference, etc.) and each such word is automatically linked to its definition.

Less typing means fewer errors and more time to concentrate on the contents. Also, because it is the computer that adds the links and much of the oher mark-up, the final documents are more consistent. At the same time, the document the authors work on is still a complete HTML document that can be edited and viewed in any normal HTML tool. It just has fewer links and a little fewer colors than the final document.

Such consistent documents have several advantages. For example, the table of content, the index and the list of properties are all created automatically. Also, various automatic checks can be performed before publishing a document, e.g.: are all properties that occur in the text also defined? are all grammars complete? are all examples valid? are all bibliographic references defined?

The CSS3 source mark-up

The way the authors write the CSS3 modules is not always the way the documents appear once published. The mark-up that the authors use is included here, even though readers never see it.

Two important characteristics of this mark-up (and of the programs that work on it) are:


Properties are single words enclosed in single straight quotes, e.g.,


That is all that the author has to type. Such quoted words automatically get enclosed in an <a> element with class “property” that links to the definition of the property:

<a class=property
<a class=property

All occurrences of property names are marked-up like this, except when they occur in an example or a some CSS code. The definition of the property also doesn't get quotes.

Inline CSS code and CSS keywords

Inline CSS is also enclosed in single quotes or in two pairs of single quotes, e.g.:

'color: blue'
''display: none''

The author only types the quotes, the text is automatically wrapped in a <span> with class “css” during publication. If the quotes were doubled, one pair is removed:

<span class=css>'color: blue'</span>
<span class=css>'display: none'</span>

CSS keywords (other than property names) must be typed by the author with a double pair of single quotes, in order to distinguish them from properties:


The result in the published document is a word with single quotes and a <span> as above:

<span class=css>'none'</span>

Value types

Value types are enclosed in angle brackets and in a <var> element. E.g.:


[The mark-up of the definitions of such types has not been decided yet.]

Cross-references and defined terms

The defining instance of a term is enclosed in a <dfn> element (which means it will also end up in the alphabetic index):


To refer to the definition, the author only has to enclose the usage in some inline element (<em>, <span>, etc.) and the usage will automatically be wrapped in an <a> element that links to the defining instance.

If the usage and definition aren't literally the same, the title attribute can be used to give the exact term:

<dfn title="dog">dogs</dfn>
<span title="dog">dog</span>

The result looks like this:

<dfn id=dogs0 title="dog">dogs</dfn>
<em><a href="#gogs0">dog</a></em>
<span title="dog"><a href="#dogs0">dog</a></span>

Property definitions

Property definitions consists of a table like this:

Name: padding
Value: [ <length> | <percentage> ]{1,4}
Initial: (see individual properties)
Applies to: all elements
Inherited: no
Animatable: yes
Percentages: width* of containing block
Media: visual
Computed value: see individual properties
Canonical order: N/A
*) if the containing block is horizontal, otherwise the height

Which is created like this:

<table class=propdef>
  <td>[ <var>&lt;length&gt;</var>
   | <var>&lt;percentage&gt;</var> ]{1,4}
  <td>(see individual properties)
  <td>all elements
  <td>width* of containing block
  <td>see individual properties
  <td colspan=2 class=footnote>*) if the
   containing block is horizontal, otherwise
   the height

The table has a class of “propdef” and the name of the property that is being defined is enclosed in <dfn> (but not in single quotes). When the document is published, an ID attribute is automatically added to the <dfn> and the property name is added to the alphabetical index and the index of properties.

Descriptor definitions

The definition of descriptors (the characteristics of fonts, inside an @font-face rule) are similar. They look like this:

Name: x-height
Value: <number>
Initial: undefined
Media: visual

The table has a class of “descdef” and looks like this:

<table class="descdef">
<tr><td>Name: <td><dfn>x-height</dfn>
<tr><td>Value: <td>&lt;number&gt;
<tr><td>Initial: <td>undefined
<tr><td>Media: <td>visual

Bibliograpic references

There are two kinds of bibliographic references: normative ones and informative ones. The author types the former as


where “CSS3BOX” and “UNICODE4” are the labels of entries that are defined in an external refer(1) database. Informative references are the same, but without the exclamation mark:


It is possible to add entries to the bibliography without any occurrence of a corresponding [[…]] in the text, by putting the label inside {{…}} in a comment:

<!-- {{CSS3BG}} -->

In the published document, [[…]] references are expanded into links to the bibliography as follows:

<a href="#CSS3BOX"
<a href="#UNICODE4"
<a href="#SELECT"
<a href="#MEDIAQ"

The reason for the inclusion of the comment is that it allows the final document to be edited, without removing the <a> elements, and the bibliography to be regenerated, despite the lack of double square brackets. (In theory, published specifications are never changed, but practice and theory aren't always the same…)


The bibliography is generated automatically from the bibliographic references and the data in an external bibliographic database. The result is inserted at the place of the following two comments in the source:


The former for the list of normative references, the latter for the informative references. The result in the published document looks like this:

  <!-- Sorted by label -->

  <dl class=bibliography>
   <dt style="display: none">
    <!-- keeps the doc valid if the DL is empty -->

   <dt id=CSS3LINE>[CSS3LINE]

   <dd>Michel Suignard; Eric A. Meyer. <cite>CSS3
    module: line.</cite> 15 May 2002. W3C Working
    Draft. (Work in progress.) URL: <a

   <dt id=CSS3SYN>[CSS3SYN]

   <dd>L. David Baron. <cite>CSS3 module:
    Syntax.</cite> 13 August 2003. W3C
    Working Draft. (Work in progress.) URL: <a

Index terms

The simplest mark-up that puts a word or phrase in the alphabetic index is a <span> with class “index”:

<span class=index>containing block</span>

When the term should appear in the index differently from the way it appears in the text, the title attribute holds the text for the index:

<span class=index title="box">boxes</span>
<span class=index title="inherited value">inherit
 a value</span>

When the term should appear in the index under two or more different entries, the title attribute contains the various entries separated by vertical bars:

<span class=index title="outer edge|margin edge">
 outer (margin) edge</span>

When the term should appear as a sub-entry of another term, the title attribute contains the entry and the sub-entry separated by two exclamation marks:

<span class=index title="edge!!outer">
 outer edge</span>
<span class=index title="edge!!inner">
 inner edge</span>

Of course, sub-terms and multiple terms can be combined:

<span class=index title="edge!!outer|edge!!margin">
 outer edge</span>

If an occurrence is considered the defining instance of the term, the element <dfn> replaces the span and the class is omitted:


The title attribute can be put on the <dfn> element exactly as on the <span>.

All index terms automatically get an ID attribute.


The alphabetic index that is generated from the index terms is automatically inserted in the document at the place of the following comment:


The expanded result looks like this:

<ul class=indexlist>
  <a href="#anonymous0"><strong>#</strong></a>
  <a href="#writing-mode"><strong>#</strong></a>


Examples are marked-up with a class of “example” and they can be either <div> or <pre>. The former if the example includes explanatory text or images, the latter if the example consists of nothing but code:

<div class=example>

<pre class=example>


Figures normally have a caption. The figure and the caption are enclosed in a <div> with class “figure” like this:

<div class="figure">
  <p><img src="box.png"
   alt="Boxes have four sides [schema]">
  <p class=caption>Relation between four…


The class “note” indicates a non-normative note. It is typically used on a <p>, <div> or <span>.

<p class=note>Note that the…

Section numbers

Section numbers are usually added automatically. They are enclosed in a span with class “secno” and look like this:

<span class=secno>1. </span>

Subsections are numbered 1.1., 1.1.1, etc.


A CSS3 module has only one <h1> element, which is the same as the <title> element (apart possibly from punctuation and abbreviations).

Table of contents

The table of contents is automatically generated and inserted at the place of the following comment:


The result looks like this:

<ul class=toc>
 <li><a href="#dependencies"><span class=secno>1.
  </span>Dependencies on
  other modules</a>
 <li><a href="#introduction"><span class=secno>2.

The CSS2 source mark-up

[To do]


Since 2014, most CSS specifications are generated with Tab Atkin's Bikeshed.

Before that, the CSS WG used a variety of private tools to process, test and otherwise use the specifications that are marked-up as above. Some tools are CGI scripts, some are Perl programs or sed scripts, combined with various C tools in the HTML-XML utilities.

Bert Bos, style activity lead
Copyright © 1994–2022 W3C® Privacy policy

Made with    CSS! Valid CSS! Last updated Thu 31 Mar 2022 08:28:11 PM UTC


About the translations