outline

  • Revision slug: CSS/outline
  • Revision title: outline
  • Revision id: 25552
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 5 words removed

Revision Content

{{ CSSRef() }}

Summary

The outline CSS 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
<style type="text/css"></style>
  • {{ Xref_cssinitial() }}: see individual properties for details
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}, {{ Xref_cssinteractive() }}
  • Computed value: see individual properties

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

Syntax

outline:  [ <outline-width> || <outline-style> || <outline-color> ] | inherit

Values

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

outline-width
Optional, default value medium is used if absent. See {{ Cssxref("outline-width") }}.
outline-style
Required, default value none is used if absent. See {{ Cssxref("outline-style") }}.
outline-color
Optional, default value if absent: invert. 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

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.0 6.0 3.1

See also

{{ CSS_Reference:Outline() }}

{{ languages( { "fr": "fr/CSS/outline", "pl": "pl/CSS/-moz-outline" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h3 id="Summary">Summary</h3>
<p>The<code> outline </code>CSS 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; outline: 1px dotted;">TEXT<span style="font-size: xx-large;">TEXT</span>TEXT</strong></li>
</ul>
<nobr>
<style type="text/css"><![CDATA[.cssprop {
  display:table;
  padding: 0.4em;
  border-left:0.15em solid;
  background-color:#eeeeff
}
.cssprop li {
 display:table-row;
 padding: 3px;
 margin:0;
}
.cssprop li dfn {
  display:table-cell;
  padding: 0 5px;
  border-bottom: none;
  cursor:inherit;
}

]]></style>
<ul class="cssprop"> <li><dfn>{{ Xref_cssinitial() }}:</dfn> see individual properties for details</li> <li><dfn>Applies to:</dfn> all elements</li> <li><dfn>{{ Xref_cssinherited() }}:</dfn> no</li> <li><dfn>Media:</dfn> {{ Xref_cssvisual() }}, {{ Xref_cssinteractive() }}</li> <li><dfn>Computed value:</dfn> see individual properties</li>
</ul>
<p>In browsers previous to <a href="/en/Gecko" title="en/Gecko">Gecko</a> 1.8 (<a href="/en/Firefox_1.5_for_developers" title="en/Firefox_1.5_for_developers">Firefox 1.5</a>) a similar effect can be achieved using <a href="/en/CSS/CSS_Reference/Mozilla_Extensions" title="en/CSS_Reference/Mozilla_Extensions">Mozilla CSS Extension</a> {{ Cssxref("-moz-outline") }}.</p></nobr><h3 id="Syntax">Syntax</h3>
<pre class="eval">outline:  [ &lt;outline-width&gt; || &lt;outline-style&gt; || &lt;outline-color&gt; ] | inherit
</pre>
<h3 id="Values">Values</h3>
<p>One, two or three values, given in arbitrary order:</p>
<dl> <dt>outline-width</dt> <dd><em>Optional</em>, default value<code> medium </code>is used if absent. See {{ Cssxref("outline-width") }}.</dd> <dt>outline-style</dt> <dd><em>Required</em>, default value<code> none </code>is used if absent. See {{ Cssxref("outline-style") }}.</dd> <dt>outline-color</dt> <dd><em>Optional</em>, default value if absent:<code> invert</code>. 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><h3 id="Examples">Examples</h3>
<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>
<h3 id="Specifications">Specifications</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/CSS21/ui.html#dynamic-outlines" title="http://www.w3.org/TR/CSS21/ui.html#dynamic-outlines">CSS 2.1 User Interface #outline</a></li> <li><a class="external" href="http://www.w3.org/TR/css3-ui/#outline1" title="http://www.w3.org/TR/css3-ui/#outline1">CSS 3 Basic User Interface Module #outline</a></li>
</ul>
<h3 id="Browser_Compatibility" name="Browser_Compatibility">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 (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") }}</td> <td>8.0</td> <td>6.0</td> <td>3.1</td> </tr> </tbody> </table>
</div>
<h3 id="See_also">See also</h3>
<p>{{ CSS_Reference:Outline() }}</p>
<p>{{ languages( { "fr": "fr/CSS/outline", "pl": "pl/CSS/-moz-outline" } ) }}</p>
Revert to this revision