mozilla

Revision 41254 of :disabled

  • Revision slug: CSS/:disabled
  • Revision title: :disabled
  • Revision id: 41254
  • Created:
  • Creator: McGurk
  • Is current revision? No
  • Comment 17 words added, 13 words removed

Revision Content

{{ CSSRef() }}

Summary

The :disabled pseudo-class represents any disabled element. An element is disabled if it can't be activated (e.g. selected, clicked on or accept text input) or accept focus. The element also has an enabled state, in which it can be activated or accept focus.

Examples

Example selectors

input:disabled
Selects all disabled inputs
select.country:disabled
Targets a select element with class country that is disabled

Usage example

The following CSS:

.input[type="text"]:disabled {background:#ccc}

applied to this HTML5 fragment:

<form action="#">
  <fieldset>
    <legend>Shipping address</legend>
    <input type="text" name="shipping_firstName" disabled>
    <input type="text" name="shipping_lastName" disabled>
    <input type="text" name="shipping_address1" disabled>
    <input type="text" name="shipping_address2" disabled>
    <input type="text" name="shipping_zipCode" disabled>
    <input type="text" name="shipping_town" disabled>
  </fieldset>
  <fieldset>
    <legend>Billing address</legend>
    <label>
      <input type="checkbox" name="billing_is_shipping" value="true" checked> 
      Billing address is the same as shipping address
    </label>
    <input type="text" name="billing_firstName" disabled>
    <input type="text" name="billing_lastName" disabled>
    <input type="text" name="billing_address1" disabled>
    <input type="text" name="billing_address2" disabled>
    <input type="text" name="billing_zipCode" disabled>
    <input type="text" name="billing_town" disabled>
  </fieldset>
</form>

Will result in all text elements in the billing fieldset having a light grey background.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{ CompatGeckoDesktop("1") }} 9.0 9.0 3.1
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 2.1 {{ CompatGeckoMobile("1") }} 9.0 9.5 3.1

Specifications

See also

Revision Source

<p>{{ CSSRef() }}</p>
<h3>Summary</h3>
<p>The <code>:disabled</code> <a href="/en/CSS/Pseudo-classes" title="Pseudo-classes">pseudo-class</a> represents any disabled element. An element is disabled if it can't be activated (e.g. selected, clicked on or accept text input) or accept focus. The element also has an enabled state, in which it can be activated or accept focus.</p>
<h3>Examples</h3>
<h4>Example selectors</h4>
<dl> <dt>input:disabled</dt> <dd>Selects all disabled inputs</dd> <dt>select.country:disabled</dt> <dd>Targets a select element with class country that is disabled</dd>
</dl>
<h4>Usage example</h4>
<p>The following CSS:</p>
<pre><code>.input[type="text"]:disabled {background:#ccc}</code>
</pre>
<p>applied to this HTML5 fragment:</p>
<pre>&lt;form action="#"&gt;
  &lt;fieldset&gt;
    &lt;legend&gt;Shipping address&lt;/legend&gt;
    &lt;input type="text" name="shipping_firstName" disabled&gt;
    &lt;input type="text" name="shipping_lastName" disabled&gt;
    &lt;input type="text" name="shipping_address1" disabled&gt;
    &lt;input type="text" name="shipping_address2" disabled&gt;
    &lt;input type="text" name="shipping_zipCode" disabled&gt;
    &lt;input type="text" name="shipping_town" disabled&gt;
  &lt;/fieldset&gt;
  &lt;fieldset&gt;
    &lt;legend&gt;Billing address&lt;/legend&gt;
    &lt;label&gt;
      &lt;input type="checkbox" name="billing_is_shipping" value="true" checked&gt; 
      Billing address is the same as shipping address
    &lt;/label&gt;
    &lt;input type="text" name="billing_firstName" disabled&gt;
    &lt;input type="text" name="billing_lastName" disabled&gt;
    &lt;input type="text" name="billing_address1" disabled&gt;
    &lt;input type="text" name="billing_address2" disabled&gt;
    &lt;input type="text" name="billing_zipCode" disabled&gt;
    &lt;input type="text" name="billing_town" disabled&gt;
  &lt;/fieldset&gt;
&lt;/form&gt;
</pre>
<p>Will result in all text elements in the billing fieldset having a light grey background.</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>1.0</td> <td>{{ CompatGeckoDesktop("1") }}</td> <td>9.0</td> <td>9.0</td> <td>3.1</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>2.1</td> <td>{{ CompatGeckoMobile("1") }}</td> <td>9.0</td> <td>9.5</td> <td>3.1</td> </tr> </tbody> </table>
</div> <h3 class="editable"><span>Specifications</span></h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/css3-selectors/#enableddisabled" rel="external nofollow" target="_blank" title="http://www.w3.org/TR/css3-selectors/#enableddisabled">CSS3 Selectors :enabled :disabled</a> Proposed Recommendation</li> <li><a class="external" href="http://www.whatwg.org/specs/web-forms/current-work/#relation" rel="external nofollow" target="_blank" title="http://www.whatwg.org/specs/web-forms/current-work/#relation">WHATWG web-forms</a></li>
</ul> <h3>See also</h3>
<ul> <li><a href="/En/CSS/:enabled" title="En/CSS/:enabled">:enabled</a></li>
</ul>
Revert to this revision