Revision 449495 of Pseudo-classes

  • Revision slug: Web/CSS/Pseudo-classes
  • Revision title: Pseudo-classes
  • Revision id: 449495
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

A CSS pseudo-class is a keyword added to selectors that specifies a special state of the element to be selected. For example {{ Cssxref(":hover") }} will apply a style when the user hovers over the element specified by the selector.

Pseudo-classes, together with pseudo-elements, let you apply a style to an element not only in relation to the content of the document tree, but also in relation to external factors like the history of the navigator ({{ cssxref(":visited") }}, for example), the status of its content (like {{ cssxref(":checked") }} on some form elements), or the position of the mouse (like {{ cssxref(":hover") }} which lets you know if the mouse is over an element or not).

Syntax

selector:pseudo-class {
  property: value;
} 

Index of standard pseudo-classes

  • {{ Cssxref(":active") }}
  • {{ Cssxref(":checked") }}
  • {{ Cssxref(":default") }}
  • {{ Cssxref(":dir", ":dir()")}}
  • {{ Cssxref(":disabled") }}
  • {{ Cssxref(":empty") }}
  • {{ Cssxref(":enabled") }}
  • {{ Cssxref(":first") }}
  • {{ Cssxref(":first-child") }}
  • {{ Cssxref(":first-of-type") }}
  • {{ Cssxref(":fullscreen") }}
  • {{ Cssxref(":focus") }}
  • {{ Cssxref(":hover") }}
  • {{ Cssxref(":indeterminate") }}
  • {{ Cssxref(":in-range") }}
  • {{ Cssxref(":invalid") }}
  • {{ Cssxref(":lang", ":lang()") }}
  • {{ Cssxref(":last-child") }}
  • {{ Cssxref(":last-of-type") }}
  • {{ Cssxref(":left") }}
  • {{ Cssxref(":link") }}
  • {{ Cssxref(":not", ":not()") }}
  • {{ Cssxref(":nth-child", ":nth-child()") }}
  • {{ Cssxref(":nth-last-child", ":nth-last-child()") }}
  • {{ Cssxref(":nth-last-of-type", ":nth-last-of-type()") }}
  • {{ Cssxref(":nth-of-type", ":nth-of-type()") }}
  • {{ Cssxref(":only-child") }}
  • {{ Cssxref(":only-of-type") }}
  • {{ Cssxref(":optional") }}
  • {{ Cssxref(":out-of-range") }}
  • {{ Cssxref(":read-only") }}
  • {{ Cssxref(":read-write") }}
  • {{ Cssxref(":required") }}
  • {{ Cssxref(":right") }}
  • {{ Cssxref(":root") }}
  • {{ Cssxref(":scope") }}
  • {{ Cssxref(":target") }}
  • {{ Cssxref(":valid") }}
  • {{ Cssxref(":visited") }}

 

Revision Source

<p>{{ CSSRef() }}</p>
<p>A CSS <strong><em><dfn>pseudo-class</dfn></em></strong> is a keyword added to selectors that specifies a special state of the element to be selected. For example {{ Cssxref(":hover") }} will apply a style when the user hovers over the element specified by the selector.</p>
<p>Pseudo-classes, together with pseudo-elements, let you apply a style to an element not only in relation to the content of the document tree, but also in relation to external factors like the history of the navigator ({{ cssxref(":visited") }}, for example), the status of its content (like {{ cssxref(":checked") }} on some form elements), or the position of the mouse (like {{ cssxref(":hover") }} which lets you know if the mouse is over an element or not).</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox">
selector:pseudo-class {
  property: value;
} 
</pre>
<h2 id="Index_of_standard_pseudo-classes">Index of standard pseudo-classes</h2>
<div class="index">
  <ul>
    <li>{{ Cssxref(":active") }}</li>
    <li>{{ Cssxref(":checked") }}</li>
    <li>{{ Cssxref(":default") }}</li>
    <li>{{ Cssxref(":dir", ":dir()")}}</li>
    <li>{{ Cssxref(":disabled") }}</li>
    <li>{{ Cssxref(":empty") }}</li>
    <li>{{ Cssxref(":enabled") }}</li>
    <li>{{ Cssxref(":first") }}</li>
    <li>{{ Cssxref(":first-child") }}</li>
    <li>{{ Cssxref(":first-of-type") }}</li>
    <li>{{ Cssxref(":fullscreen") }}</li>
    <li>{{ Cssxref(":focus") }}</li>
    <li>{{ Cssxref(":hover") }}</li>
    <li>{{ Cssxref(":indeterminate") }}</li>
    <li>{{ Cssxref(":in-range") }}</li>
    <li>{{ Cssxref(":invalid") }}</li>
    <li>{{ Cssxref(":lang", ":lang()") }}</li>
    <li>{{ Cssxref(":last-child") }}</li>
    <li>{{ Cssxref(":last-of-type") }}</li>
    <li>{{ Cssxref(":left") }}</li>
    <li>{{ Cssxref(":link") }}</li>
    <li>{{ Cssxref(":not", ":not()") }}</li>
    <li>{{ Cssxref(":nth-child", ":nth-child()") }}</li>
    <li>{{ Cssxref(":nth-last-child", ":nth-last-child()") }}</li>
    <li>{{ Cssxref(":nth-last-of-type", ":nth-last-of-type()") }}</li>
    <li>{{ Cssxref(":nth-of-type", ":nth-of-type()") }}</li>
    <li>{{ Cssxref(":only-child") }}</li>
    <li>{{ Cssxref(":only-of-type") }}</li>
    <li>{{ Cssxref(":optional") }}</li>
    <li>{{ Cssxref(":out-of-range") }}</li>
    <li>{{ Cssxref(":read-only") }}</li>
    <li>{{ Cssxref(":read-write") }}</li>
    <li>{{ Cssxref(":required") }}</li>
    <li>{{ Cssxref(":right") }}</li>
    <li>{{ Cssxref(":root") }}</li>
    <li>{{ Cssxref(":scope") }}</li>
    <li>{{ Cssxref(":target") }}</li>
    <li>{{ Cssxref(":valid") }}</li>
    <li>{{ Cssxref(":visited") }}</li>
  </ul>
</div>
<p>&nbsp;</p>
Revert to this revision