outline
Quick Summary for outline
The outline CSS shorthand property set all the outline properties in a single declaration.
Code Usage for outline

<pre class="brush: css notranslate"><code><span class="token comment">/ style /</span> <span class="token property">outline</span><span class="token punctuation">:</span> solid<span class="token punctuation">;</span> <span class="token comment">/ color | style /</span> <span class="token property">outline</span><span class="token punctuation">:</span> #f66 dashed<span class="token punctuation">;</span> <span class="token comment">/ style | width /</span> <span class="token property">outline</span><span class="token punctuation">:</span> inset thick<span class="token punctuation">;</span> <span class="token comment">/ color | style | width /</span> <span class="token property">outline</span><span class="token punctuation">:</span> green solid 3px<span class="token punctuation">;</span> <span class="token comment">/ Global values /</span> <span class="token property">outline</span><span class="token punctuation">:</span> inherit<span class="token punctuation">;</span> <span class="token property">outline</span><span class="token punctuation">:</span> initial<span class="token punctuation">;</span> <span class="token property">outline</span><span class="token punctuation">:</span> revert<span class="token punctuation">;</span> <span class="token property">outline</span><span class="token punctuation">:</span> unset<span class="token punctuation">;</span> </code></pre>

More Details for outline

outline

The outline CSS shorthand property set all the outline properties in a single declaration.

Constituent properties

This property is a shorthand for the following CSS properties:

outline-color outline-style outline-width

Syntax

/* style */ outline: solid;  /* color | style */ outline: #f66 dashed;  /* style | width */ outline: inset thick;  /* color | style | width */ outline: green solid 3px;  /* Global values */ outline: inherit; outline: initial; outline: revert; outline: unset; 

The outline property may be specified using one, two, or three of the values listed below. The order of the values does not matter.

Note: The outline will be invisible for many elements if its style is not defined. This is because the style defaults to none. A notable exception is input elements, which are given default styling by browsers.

Values

<'outline-color'>

Sets the color of the outline. Defaults to currentcolor if absent. See outline-color.

<'outline-style'>

Sets the style of the outline. Defaults to none if absent. See outline-style.

<'outline-width'>

Sets the thickness of the outline. Defaults to medium if absent. See outline-width.

Description

Borders and outlines are very similar. However, outlines differ from borders in the following ways:

Outlines never take up space, as they are drawn outside of an element's content. According to the spec, outlines don't have to be rectangular, although they usually are.

As with all shorthand properties, any omitted sub-values will be set to their initial value.

Accessibility concerns

Assigning outline a value of 0 or none will remove the browser's default focus style. If an element can be interacted with it must have a visible focus indicator. Provide obvious focus styling if the default focus style is removed.

How to Design Useful and Usable Focus Indicators WCAG 2.1: Understanding Success Criterion 2.4.7: Focus Visible

Formal definition

Initial valueas each of the properties of the shorthand:outline-color: invert, for browsers supporting it, currentColor for the otheroutline-style: noneoutline-width: medium
Applies toall elements
Inheritedno
Computed valueas each of the properties of the shorthand:outline-color: For the keyword invert, the computed value is invert. For the color value, if the value is translucent, the computed value will be the rgba() corresponding one. If it isn't, it will be the rgb() corresponding one. The transparent keyword maps to rgba(0,0,0,0).outline-width: an absolute length; if the keyword none is specified, the computed value is 0outline-style: as specified
Animation typeas each of the properties of the shorthand:outline-color: a coloroutline-width: a lengthoutline-style: discrete

Formal syntax

[ <'outline-color'> || <'outline-style'> || <'outline-width'> ]

Examples

Using outline to set a focus style

HTML
<a href="#">This link has a special focus style.</a> 
CSS
a {   border: 1px solid;   border-radius: 3px;   display: inline-block;   margin: 10px;   padding: 5px; }  a:focus {   outline: 4px dotted #e73;   outline-offset: 4px;   background: #ffa; } 
Result

Specifications

Specification
CSS Basic User Interface Module Level 4 # outline

See also

outline-color outline-style outline-width Select your preferred language English (US)DeutschEspañolFrançais日本語한국어PolskiPortuguês (do Brasil)中文 (简体) Change language

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
OpenClaw 2026.2.26 (bc50708) — If it works, it's automation; if it breaks, it's a "learning opportunity."
Latest News
## 🚀 AI Giants Hit Bullseye: Anthropic & OpenAI Achieve Product-Market Fit Anthropic and OpenAI have reached a significant milestone, finding product-market fit with their AI technologies, which means their products effectively meet the needs of their customers, driving growth and adoption. This achievement showcases the practical value of their innovations, enabling businesses and individuals to leverage AI for enhanced productivity and efficiency. With this alignment of product and market needs, these companies are poised to transform industries and shape the future of technology.