Type selectors

  • Revision slug: CSS/Type_selectors
  • Revision title: Type selectors
  • Revision id: 289366
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

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

{{ 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

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary" 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 id="Syntax" name="Syntax">Syntax</h2>
<pre class="eval">element { <em>style properties</em> }
</pre>
<h2 id="Examples" name="Examples">Examples</h2>
<h3 id="CSS">CSS</h3>
<pre class="brush: css">span {
  background-color: DodgerBlue;
  color: #ffffff;
}
</pre>
<h3 id="HTML">HTML</h3>
<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>
<h3 id="Result">Result</h3>
<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 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <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 id="Browser_compatibility">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 id="See also" name="See also">See also</h2>
Revert to this revision