mozilla

Revision 20590 of content

  • Revision slug: CSS/content
  • Revision title: content
  • Revision id: 20590
  • Created:
  • Creator: grendel
  • Is current revision? No
  • Comment Migrated data to new compatibility table and added Chrome support data.; 15 words added, 50 words removed

Revision Content

{{ CSSRef() }}

Summary

The content CSS property is used with the {{ cssxref(":before") }} and {{ cssxref(":after") }} pseudo-elements to generate content in an element.

  • {{ Xref_cssinitial() }}: {{ Cssxref("normal") }}
  • Applies to: pseudo-elements :before and :after
  • {{ Xref_cssinherited() }}: no
  • Media: all
  • {{ Xref_csscomputed() }}:
    • on :before and :after, normal computes to none
    • on elements, always computes to normal
    • for URI values, the absolute URI
    • for attr() values, the resulting string
    • for other keywords, as specified.

Syntax

content: normal | none | 
       [ <string> | <uri> | <counter> | attr() | 
         open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit

Values

none
The pseudo-element is not generated.
normal
Computes to none for the :before and :after pseudo-elements.
<string>
Text content.
<uri> url()
The value is a URI that designates an external resource (such as an image). If the resource or image can't be displayed, it is either ignored or some placeholder shows up.
<counter>
[fixme] Counters may be specified with two different functions: 'counter()' or 'counters()'. The former has two forms: 'counter(name)' or 'counter(name, style)'. 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 style ('decimal' by default). The latter function also has two forms: 'counters(name, string)' or 'counters(name, string, style)'. 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 style ('decimal' by default). See the section on automatic counters and numbering for more information. The name must not be 'none', 'inherit' or 'initial'. Such a name causes the declaration to be ignored.
attr(X)
Returns the value of the element's attribute X as a string. If there is no attribute X, an empty string is returned. The case-sensitivity of attribute names depends on the document language.
open-quote | close-quote
These values are replaced by the appropriate string from the {{ cssxref("quotes") }} property.
no-open-quote | no-close-quote
Introduces no content, but increments (decrements) the level of nesting for quotes.

Examples

 q:lang(en) { quotes: '"' '"' "'" "'" }
 q:before   { content: open-quote }
 q:after    { content: close-quote }
 h1:before  { content: "Chapter: "; }
           /* content accepts multiple values */

 a:before   { content: url(http://www.mozilla.org/favicon.ico) " MOZILLA: "; 
              font:    x-small Arial,freeSans,sans-serif;
              color:   gray;
            }

Specifications

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 1.0 (1.0) 8.0 4.0 (url() 7.0) 1.0 (85)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

{{ Cssxref(":after") }}, {{ Cssxref(":before") }}, {{ Cssxref("quotes") }}

{{ languages( { "es": "es/CSS/content" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h3>Summary</h3>
<p>The<code> content </code>CSS property is used with the {{ cssxref(":before") }} and {{ cssxref(":after") }} pseudo-elements to generate content in an element.</p>
<ul> <li>{{ Xref_cssinitial() }}: {{ Cssxref("normal") }}</li> <li>Applies to: pseudo-elements<code> :before </code>and<code> :after</code></li> <li>{{ Xref_cssinherited() }}: no</li> <li>Media: all</li> <li>{{ Xref_csscomputed() }}: <ul> <li>on<code> :before </code>and<code> :after</code>,<code> normal </code>computes to<code> none </code></li> <li>on elements, always computes to<code> normal</code></li> <li>for URI values, the absolute URI</li> <li>for<code> attr() </code>values, the resulting string</li> <li>for other keywords, as specified.</li> </ul> </li>
</ul>
<h3>Syntax</h3>
<pre>content: normal | none | 
       [ &lt;string&gt; | &lt;uri&gt; | &lt;counter&gt; | attr() | 
         open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit</pre>
<h3>Values</h3>
<dl> <dt>none</dt> <dd>The pseudo-element is not generated.</dd> <dt>normal</dt> <dd>Computes to<code> none </code>for the<code> :before </code>and<code> :after </code>pseudo-elements.</dd> <dt>&lt;string&gt;</dt> <dd>Text content.</dd> <dt>&lt;uri&gt;<code> url()</code></dt> <dd>The value is a URI that designates an external resource (such as an image). If the resource or image can't be displayed, it is either ignored or some placeholder shows up.</dd> <dt>&lt;counter&gt;</dt> <dd>[fixme] Counters 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 style ('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 style ('decimal' by default). See the section on automatic counters and numbering for more information. The name must not be 'none', 'inherit' or 'initial'. Such a name causes the declaration to be ignored.</dd> <dt>attr(X)</dt> <dd>Returns the value of the element's attribute X as a string. If there is no attribute X, an empty string is returned. The case-sensitivity of attribute names depends on the document language.</dd> <dt>open-quote | close-quote</dt> <dd>These values are replaced by the appropriate string from the {{ cssxref("quotes") }} property.</dd> <dt>no-open-quote | no-close-quote</dt> <dd>Introduces no content, but increments (decrements) the level of nesting for quotes.</dd>
</dl>
<h3>Examples</h3>
<pre> q:lang(en) { quotes: '"' '"' "'" "'" }
 q:before   { content: open-quote }
 q:after    { content: close-quote }</pre>
<pre> h1:before  { content: "Chapter: "; }</pre>
<pre>           /* content accepts multiple values */

 a:before   { content: url(http://www.mozilla.org/favicon.ico) " MOZILLA: "; 
              font:    x-small Arial,freeSans,sans-serif;
              color:   gray;
            }</pre>
<h3>Specifications</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/CSS21/generate.html" title="http://www.w3.org/TR/CSS21/generate.html">CSS 2.1 Generated content</a></li>
</ul>
<h3 name="Browser_Compatibility">Browser compatibility</h3>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
<table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari (WebKit)</th> </tr> <tr> <td>Basic support</td> <td>1.0</td> <td>1.0 (1.0)</td> <td>8.0</td> <td>4.0 (<code>url()</code> 7.0)</td> <td>1.0 (85)</td> </tr> </tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody>
</table>
</div>
<h3>See also</h3>
<p>{{ Cssxref(":after") }}, {{ Cssxref(":before") }}, {{ Cssxref("quotes") }}</p>
<p>{{ languages( { "es": "es/CSS/content" } ) }}</p>
Revert to this revision