outline

  • Revision slug: CSS/outline
  • Revision title: outline
  • Revision id: 386035
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

{{CSSRef}}

Summary

The CSS outline property is a shorthand property for setting one or more of the individual outline properties {{cssxref("outline-style")}}, {{cssxref("outline-width")}} and {{cssxref("outline-color")}} in a single rule. In most cases the use of this shortcut is preferable and more convenient.

Outlines differ from borders in the following ways:

  • Outlines do not take up space, they are drawn above the content.
  • Outlines may be non-rectangular. They are rectangular in Gecko/Firefox. But e.g. Opera draws a non-rectangular shape around a construct like this:
    TEXTTEXTTEXT
{{cssbox("outline")}}

Syntax

Formal syntax: {{csssyntax("outline")}}

Values

One, two or three values, given in arbitrary order:

<'outline-width'>
See {{Cssxref("outline-width")}}.
<'outline-style'>
See {{Cssxref("outline-style")}}.
<'outline-color'>
Since Gecko 1.9 (Firefox 3), the value of the element's {{Cssxref("color")}} property (foreground color) is used. See {{Cssxref("outline-color")}}.

Examples

outline: solid; | outline: dashed red; | outline: dotted 1px; | outline: ridge thick violet; | outline: custom 5px;
/* two identical declarations */

:link:hover { outline: 1px solid #000 }
:link:hover { outline: solid black 1px }

Specifications

Specification Status Comment
{{SpecName('CSS3 UI', '#outline', 'outline')}} {{Spec2('CSS3 UI')}} No change.
{{SpecName('CSS2.1', 'ui.html#propdef-outline', 'outline')}} {{Spec2('CSS2.1')}}  

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 1.5 (1.8) 8.0 7.0 1.2 (125)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 1.0 {{CompatGeckoMobile(1.8)}} 8.0 6.0 3.1

In browsers previous to Gecko 1.8 (Firefox 1.5) a similar effect can be achieved using Mozilla CSS Extension {{Cssxref("-moz-outline")}}.

See also

  • {{CSS_Reference:Outline}}
  • {{CSS_Reference:Border}}

Revision Source

<div>{{CSSRef}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <a href="/en-US/docs/CSS" title="CSS">CSS</a> <code>outline</code> property is a shorthand property for setting one or more of the individual outline properties {{cssxref("outline-style")}}, {{cssxref("outline-width")}} and {{cssxref("outline-color")}} in a single rule. In most cases the use of this shortcut is preferable and more convenient.</p>
<p>Outlines differ from borders in the following ways:</p>
<ul>
  <li>Outlines do not take up space, they are drawn above the content.</li>
  <li>Outlines may be non-rectangular. They are rectangular in Gecko/Firefox. But e.g. Opera draws a non-rectangular shape around a construct like this:<br />
    <strong style="color: orange;">TEXT<span style="font-size: xx-large;">TEXT</span>TEXT</strong></li>
</ul>
<div>{{cssbox("outline")}}</div>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("outline")}}</pre>
<h3 id="Values" name="Values">Values</h3>
<p>One, two or three values, given in arbitrary order:</p>
<dl>
  <dt><code>&lt;'outline-width'&gt;</code></dt>
  <dd>See {{Cssxref("outline-width")}}.</dd>
  <dt><code>&lt;'outline-style'&gt;</code></dt>
  <dd>See {{Cssxref("outline-style")}}.</dd>
  <dt><code>&lt;'outline-color'&gt;</code></dt>
  <dd>Since Gecko 1.9 (Firefox 3), the value of the element's {{Cssxref("color")}} property (foreground color) is used. See {{Cssxref("outline-color")}}.</dd>
</dl>
<h2 id="Examples" name="Examples">Examples</h2>
<pre>
<span style="outline:solid">outline: solid;</span> | <span style="outline:dashed red">outline: dashed red;</span> | <span style="outline:dotted 1px">outline: dotted 1px;</span> | <span style="outline:ridge thick violet">outline: ridge thick violet;</span> | <span style="outline:ridge 5px yellow;">outline: custom 5px;</span></pre>
<pre class="brush: css">
/* two identical declarations */

:link:hover { outline: 1px solid #000 }
:link:hover { outline: solid black 1px }</pre>
<h2 id="Specifications" name="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('CSS3 UI', '#outline', 'outline')}}</td>
      <td>{{Spec2('CSS3 UI')}}</td>
      <td>No change.</td>
    </tr>
    <tr>
      <td>{{SpecName('CSS2.1', 'ui.html#propdef-outline', 'outline')}}</td>
      <td>{{Spec2('CSS2.1')}}</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<div>{{CompatibilityTable}}</div>
<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 (WebKit)</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>1.0</td>
        <td>1.5 (1.8)</td>
        <td>8.0</td>
        <td>7.0</td>
        <td>1.2 (125)</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 Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>1.0</td>
        <td>{{CompatGeckoMobile(1.8)}}</td>
        <td>8.0</td>
        <td>6.0</td>
        <td>3.1</td>
      </tr>
    </tbody>
  </table>
</div>

<p>In browsers previous to <a href="/en-US/docs/Gecko" title="Gecko">Gecko</a> 1.8 (<a href="/en-US/docs/Firefox_1.5_for_developers" title="Firefox_1.5_for_developers">Firefox 1.5</a>) a similar effect can be achieved using <a href="/en-US/docs/CSS/CSS_Reference/Mozilla_Extensions" title="CSS_Reference/Mozilla_Extensions">Mozilla CSS Extension</a> {{Cssxref("-moz-outline")}}.</p>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li>{{CSS_Reference:Outline}}</li>
  <li>{{CSS_Reference:Border}}</li>
</ul>
Revert to this revision