:valid

  • Revision slug: CSS/:valid
  • Revision title: :valid
  • Revision id: 292533
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

Summary

The :valid CSS pseudo-class represents any {{ HTMLElement("input") }} element whose content validates correctly according to the input's type setting. This allows to easily make valid fields adopt an appearance that helps the user confirm that their data is formatted properly.

Examples

See {{ cssxref(":invalid") }} for an example.

Specifications

Specification Status Comment
{{ SpecName('HTML5_W3C', '#pseudo-validity', ':valid') }} {{ Spec2('HTML5') }} Defines the semantic regarding HTML and constraint validation.
{{ SpecName('CSS3 UI', '#pseudo-validity', ':valid') }} {{ Spec2('CSS3 UI') }} Defines the pseudo-class, but not the associated semantic.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 10.0 {{ CompatGeckoDesktop("2") }} 10 10.0 5.0
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatGeckoMobile("2") }} {{ CompatNo() }} 10.0 5.0

See also

  • {{ cssxref(":invalid") }}, {{ cssxref(":required") }}, {{ cssxref(":optional") }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>:valid</code> CSS <a href="/en/CSS/Pseudo-classes" title="Pseudo-classes">pseudo-class</a> represents any {{ HTMLElement("input") }}&nbsp;element whose content <a href="/en/HTML/HTML5/Constraint_validation" title="en/HTML/HTML5/Constraint_validation">validates</a> correctly according to the input's type setting. This allows to easily make valid fields adopt an appearance that helps the user confirm that their data is formatted properly.</p>
<h2 id="Examples">Examples</h2>
<p>See {{ cssxref(":invalid") }} for an example.</p>
<h2 id="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>{{ SpecName('HTML5_W3C', '#pseudo-validity', ':valid') }}</td>
      <td>{{ Spec2('HTML5') }}</td>
      <td>Defines the semantic regarding HTML and constraint validation.</td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS3 UI', '#pseudo-validity', ':valid') }}</td>
      <td>{{ Spec2('CSS3 UI') }}</td>
      <td>Defines the pseudo-class, but not the associated semantic.</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>10.0</td>
        <td>{{ CompatGeckoDesktop("2") }}</td>
        <td>10</td>
        <td>10.0</td>
        <td>5.0</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 Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatGeckoMobile("2") }}</td>
        <td>{{ CompatNo() }}</td>
        <td>10.0</td>
        <td>5.0</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{ cssxref(":invalid") }}, {{ cssxref(":required") }}, {{ cssxref(":optional") }}</li>
</ul>
Revert to this revision