Revision 35649 of :optional

  • Revision slug: CSS/:optional
  • Revision title: :optional
  • Revision id: 35649
  • Created:
  • Creator: FredB
  • Is current revision? No
  • Comment Add compatibility support for IE; 1 words added, 4 words removed

Revision Content

{{ CSSRef() }}

Summary

The :optional CSS pseudo-class represents any {{ HTMLElement("input") }} element that does not have the {{ htmlattrxref("required","input") }} attribute set on it. This allows forms to easily indicate optional fields, and to style them accordingly.

To provide an appearance for required form fields, the {{ cssxref(":required") }} pseudo-class may be used.

Specifications

Specification Status Comment
CSS 3 Basic User Interface Module {{ Spec2('CSS3 UI') }}  

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(":required") }}
  • {{ cssxref(":invalid") }}
  • {{ cssxref(":valid") }}

{{ languages( { "fr": "fr/CSS/:optional" }) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>:optional</code> CSS <a href="/en/CSS/Pseudo-classes" title="Pseudo-classes">pseudo-class</a> represents any {{ HTMLElement("input") }} element that does not have the {{ htmlattrxref("required","input") }} attribute set on it. This allows forms to easily indicate optional fields, and to style them accordingly.</p>
<p>To provide an appearance for required form fields, the {{ cssxref(":required") }} pseudo-class may be used.</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><a class="external" href="http://www.w3.org/TR/css3-ui/#pseudo-required-value" title="http://www.w3.org/TR/css3-ui/#pseudo-required-value">CSS 3 Basic User Interface Module</a></td> <td>{{ Spec2('CSS3 UI') }}</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>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(":required") }}</li> <li>{{ cssxref(":invalid") }}</li> <li>{{ cssxref(":valid") }}</li>
</ul>
<p>{{ languages( { "fr": "fr/CSS/:optional" }) }}</p>
Revert to this revision