mozilla

Revision 9113 of Type selectors

  • Revision slug: CSS/Type_selectors
  • Revision title: Type selectors
  • Revision id: 9113
  • Created:
  • Creator: FredB
  • Is current revision? No
  • Comment 17 words added, 8 words removed

Revision Content

{{ CSSRef() }}

Summary

CSS type selectors match elements by node name. Used alone, therefore, a type selector for a particular node name selects all elements of that type — that is, with that node name — in the document.

Syntax

element { style properties }

Examples

CSS

span {
  background-color: DodgerBlue;
  color: #ffffff;
}

HTML

  <span>Here's a span with some text.</span>
  <p>Here's a p with some text.</p>

Result

Here's a span with some text.
Here's a p with some text.

Specifications

Specification Status Comment
CSS Selectors Level 3 {{ Spec2('CSS3 Selectors') }} No change
CSS 2.1 {{ Spec2('CSS2.1') }}  
CSS 1 {{ Spec2('CSS1') }}  

Browser compatibility

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

{{ languages( { "fr": "fr/CSS/Sélecteurs_de_type", "pl": "pl/CSS/Selektory_typu" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2 name="Summary">Summary</h2>
<p>CSS type selectors match elements by node name. Used alone, therefore, a type selector for a particular node name selects all elements of that type — that is, with that node name — in the document.</p>
<h2 name="Syntax">Syntax</h2>
<pre class="eval">element { <em>style properties</em> }
</pre>
<h2 name="Examples">Examples</h2>
<h4>CSS</h4>
<pre class="brush: css">span {
  background-color: DodgerBlue;
  color: #ffffff;
}
</pre>
<h4>HTML</h4>
<pre class="brush: html">  &lt;span&gt;Here's a span with some text.&lt;/span&gt;
  &lt;p&gt;Here's a p with some text.&lt;/p&gt;
</pre>
<h4>Result</h4>
<p><span style="background-color: DodgerBlue; color: #ffffff;">Here's a span with some text.</span><br> Here's a p with some text.</p>
<h2 name="Specifications">Specifications</h2>
<table class="standard-table"> <thead> <tr style="background-color: rgb(255, 204, 255);"> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td><a class="external" href="http://www.w3.org/TR/css3-selectors/#type-selectors" title="http://www.w3.org/TR/css3-selectors/#type-selectors">CSS Selectors Level 3</a></td> <td>{{ Spec2('CSS3 Selectors') }}</td> <td>No change</td> </tr> <tr> <td><a class="external" href="http://www.w3.org/TR/CSS21/selector.html#type-selectors" title="http://www.w3.org/TR/CSS21/selector.html#type-selectors">CSS 2.1</a></td> <td>{{ Spec2('CSS2.1') }}</td> <td> </td> </tr> <tr> <td><a class="external" href="http://www.w3.org/TR/CSS1/#basic-concepts" title="http://www.w3.org/TR/CSS1/#basic-concepts">CSS 1</a></td> <td>{{ Spec2('CSS1') }}</td> <td> </td> </tr> </tbody>
</table>
<h2>Browser compatibility</h2>
<h2>Browser compatibility</h2>
<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</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Chrome for Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Mobile</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> <td>{{ CompatUnknown() }}</td> </tr> </tbody> </table>
</div><h2 name="See also">See also</h2>
<p>{{ languages( { "fr": "fr/CSS/Sélecteurs_de_type", "pl": "pl/CSS/Selektory_typu" } ) }}</p>
Revert to this revision