outline

  • Revision slug: CSS/outline
  • Revision title: outline
  • Revision id: 25540
  • Created:
  • Creator: asuth
  • Is current revision? No
  • Comment Fixing spelling; 3 words added, 3 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
  • {{ Xref_cssinitial() }}: see individual properties for details
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Percentages: N/A
  • 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 color property (foreground color) is used. See {{ Cssxref("outline-color") }}.

Examples

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

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

Specifications

Browser compatibility

Browser Lowest Version
Internet Explorer 8.0
Firefox (Gecko) 1.5 (1.8)
Opera 7.0
Safari (WebKit) 1.2 (125)

See also

{{ CSS_Reference:Outline() }}

Revision Source

<p>{{ CSSRef() }}</p>
<h3>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>
<ul> <li>{{ Xref_cssinitial() }}: see individual properties for details</li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: no</li> <li>Percentages: N/A</li> <li>Media: {{ Xref_cssvisual() }}, {{ Xref_cssinteractive() }}</li> <li>Computed value: 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_Reference/Mozilla_Extensions" title="en/CSS_Reference/Mozilla_Extensions">Mozilla CSS Extension</a> {{ Cssxref("-moz-outline") }}.</p>
<h3>Syntax</h3>
<pre class="eval">outline:  [ &lt;outline-width&gt; || &lt;outline-style&gt; || &lt;outline-color&gt; ] | inherit
</pre>
<h3>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 <span class="lang lang-en"><code><a href="../../../../en/CSS/color" rel="internal">color</a></code> </span> property (foreground color) is used. See {{ Cssxref("outline-color") }}.</dd>
</dl>
<h3>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>
</pre>
<pre>/* two identical declarations */

:link:hover { outline: 1px solid #000 }
:link:hover { outline: solid black 1px }
</pre>
<h3>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>Browser compatibility</h3>
<table class="standard-table"> <tbody> <tr> <th>Browser</th> <th>Lowest Version</th> </tr> <tr> <td>Internet Explorer</td> <td><strong>8.0</strong></td> </tr> <tr> <td>Firefox (Gecko)</td> <td><strong>1.5</strong> (1.8)</td> </tr> <tr> <td>Opera</td> <td><strong>7.0</strong></td> </tr> <tr> <td>Safari (WebKit)</td> <td><strong>1.2</strong> (125)</td> </tr> </tbody>
</table>
<h3>See also</h3>
<p>{{ CSS_Reference:Outline() }}</p>
Revert to this revision