:optional

  • Revision slug: CSS/:optional
  • Revision title: :optional
  • Revision id: 35645
  • Created:
  • Creator: McGurk
  • Is current revision? No
  • Comment Updated browser compatibility; 45 words added, 6 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.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 10.0 {{ CompatGeckoDesktop("2") }} {{ CompatNo() }} 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

Specifications

See also

  • {{ cssxref(":required") }}
  • {{ cssxref(":invalid") }}
  • {{ cssxref(":valid") }}

Revision Source

<p>{{ CSSRef() }}</p>
<h3>Summary</h3>
<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>
<h3>Browser compatibility</h3>
<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>{{ CompatNo() }}</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>
<h3>Specifications</h3>
<ul> <li><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></li>
</ul>
<h3>See also</h3>
<ul> <li>{{ cssxref(":required") }}</li> <li>{{ cssxref(":invalid") }}</li> <li>{{ cssxref(":valid") }}</li>
</ul>
Revert to this revision