:default

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

Revision Content

{{ CSSRef() }}

Summary

The :default CSS pseudo-class represents any user interface element that is the default among a group of similar elements.

For example, the default button in a set of buttons could be selected using this pseudo-class.

User interface elements that permit multiple selections may have multiple defaults set in order to initially appear with multiple items selected. In that case all defaults can be represented using the :default pseudo-class.

Syntax

:default { style properties }

Examples

:default
{
    background-color: lime;
}

...where...

 <form method="get">
  <p><input type="submit" id="submit1"></p>
  <p><input type="submit" id="submit2"></p>
  <p><input type="reset"></p>
 </form>

This example causes the background color to be lime for the default submit button in the form.

Specifications

Specification Status Comment
{{ SpecName('HTML WHATWG', '#selector-default', ':default') }} {{ Spec2('HTML WHATWG') }} No change.
{{ SpecName('HTML5 W3C', '#selector-default', ':default') }} {{ Spec2('HTML5 W3C') }} Defines the semantic regarding HTML and constraint validation.
{{ SpecName('CSS4 Selectors', '#default-pseudo', ':default') }} {{ Spec2('CSS4 Selectors') }} No change.
{{ SpecName('CSS3 UI', '#pseudo-default', ':default') }} {{ 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.0") }} {{ CompatNo() }} 10.0 5.0
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatGeckoMobile("2.0") }} {{ CompatNo() }} 10.0 5.0

 

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code>:default</code> <a href="/en-US/docs/CSS" title="/en-US/docs/CSS">CSS</a> <a href="/en/CSS/Pseudo-classes" title="Pseudo-classes">pseudo-class</a> represents any user interface element that is the default among a group of similar elements.</p>
<p>For example, the default button in a set of buttons could be selected using this pseudo-class.</p>
<p>User interface elements that permit multiple selections may have multiple defaults set in order to initially appear with multiple items selected. In that case all defaults can be represented using the <code>:default</code> pseudo-class.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="eval">
:default { <em>style properties</em> }
</pre>
<h2 id="Examples" name="Examples">Examples</h2>
<pre class="brush: css">
:default
{
    background-color: lime;
}
</pre>
<p>...where...</p>
<pre class="brush: html">
 &lt;form method="get"&gt;
  &lt;p&gt;&lt;input type="submit" id="submit1"&gt;&lt;/p&gt;
  &lt;p&gt;&lt;input type="submit" id="submit2"&gt;&lt;/p&gt;
  &lt;p&gt;&lt;input type="reset"&gt;&lt;/p&gt;
 &lt;/form&gt;
</pre>
<p>This example causes the background color to be <code>lime</code> for the default submit button in the form.</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ SpecName('HTML WHATWG', '#selector-default', ':default') }}</td>
      <td>{{ Spec2('HTML WHATWG') }}</td>
      <td>No change.</td>
    </tr>
    <tr>
      <td>{{ SpecName('HTML5 W3C', '#selector-default', ':default') }}</td>
      <td>{{ Spec2('HTML5 W3C') }}</td>
      <td>Defines the semantic regarding HTML and constraint validation.</td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS4 Selectors', '#default-pseudo', ':default') }}</td>
      <td>{{ Spec2('CSS4 Selectors') }}</td>
      <td>No change.</td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS3 UI', '#pseudo-default', ':default') }}</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.0") }}</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.0") }}</td>
        <td>{{ CompatNo() }}</td>
        <td>10.0</td>
        <td>5.0</td>
      </tr>
    </tbody>
  </table>
</div>
<p>&nbsp;</p>
Revert to this revision