Type selectors

  • Revision slug: CSS/Type_selectors
  • Revision title: Type selectors
  • Revision id: 9111
  • Created:
  • Creator: FredB
  • Is current revision? No
  • Comment 2 words added, 1 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.

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="Notes">See also</h2>
<p>{{ languages( { "fr": "fr/CSS/Sélecteurs_de_type", "pl": "pl/CSS/Selektory_typu" } ) }}</p>
Revert to this revision