An outline is a line that is drawn around elements (outside the borders) to make the element "stand out".
The outline properties specifies the style, color, and width of an outline.
Examples
Draw a line around an element (outline)This example demonstrates how to draw a line around an element, outside the border edge.
Example
<html>
<head>
<style type="text/css">
p
{
border:1px solid red;
outline:green dotted thick;
}
</style>
</head>
<body>
<p><b>Note:</b> IE8 supports the outline properties only if a !DOCTYPE is
specified.</p>
</body>
</html>
Try it yourself in Notepad or Dreamweaver by coping and pasting the code above.
Set the style of an outlineThis example demonstrates how to set the style of an outline.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
p {border:1px solid red;}
p.dotted {outline-style:dotted;}
p.dashed {outline-style:dashed;}
p.solid {outline-style:solid;}
p.double {outline-style:double;}
p.groove {outline-style:groove;}
p.ridge {outline-style:ridge;}
p.inset {outline-style:inset;}
p.outset {outline-style:outset;}
</style>
</head>
<body>
<p class="dotted">A dotted outline</p>
<p class="dashed">A dashed outline</p>
<p class="solid">A solid outline</p>
<p class="double">A double outline</p>
<p class="groove">A groove outline</p>
<p class="ridge">A ridge outline</p>
<p class="inset">An inset outline</p>
<p class="outset">An outset outline</p>
<b>Note:</b> IE8 supports the outline properties only if a !DOCTYPE is
specified.
</body>
</html>
Try it yourself in Notepad or Dreamweaver by coping and pasting the code above.
Result:
A dotted outline
A dashed outline
A solid outline
A double outline
A groove outline
A ridge outline
An inset outline
An outset outline
Note: IE8 supports the outline properties only if a !DOCTYPE is specified.
Set the color of an outlineThis example demonstrates how to set the color of an outline.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
p
{
border:1px solid red;
outline-style:dotted;
outline-color:#00ff00;
}
</style>
</head>
<body>
<p><b>Note:</b> IE8 supports the outline properties only if a !DOCTYPE is specified.</p>
</body>
</html>
Try it yourself in Notepad or Dreamweaver by coping and pasting the code above.
Set the width of an outlineThis example demonstrates how to set the width of an outline.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
p.one
{
border:1px solid red;
outline-style:solid;
outline-width:thin;
}
p.two
{
border:1px solid red;
outline-style:dotted;
outline-width:3px;
}
</style>
</head>
<body>
<p class="one">This is some text in a paragraph.</p>
<p class="two">This is some text in a paragraph.</p>
<p><b>Note:</b> IE8 supports the outline properties only if a !DOCTYPE is
specified.</p>
</body>
</html>
Try it yourself in Notepad or Dreamweaver by coping and pasting the code above.
Resuly:
This is some text in a paragraph.
This is some text in a paragraph.
Note: IE8 supports the outline properties only if a !DOCTYPE is specified.CSS Outline
An outline is a line that is drawn around elements (outside the borders) to make the element "stand out".
However, the outline property is different from the border property.
The outline is not a part of an element's dimensions; the element's total width and height is not affected by the width of the outline.
All CSS Outline Properties
The number in the "CSS" column indicates in which CSS version the property is defined (CSS1 or CSS2).
| Property | Description | Values | CSS |
|---|---|---|---|
| outline | Sets all the outline properties in one declaration | outline-color outline-style outline-widthinherit | 2 |
| outline-color | Sets the color of an outline | color_name hex_number rgb_numberinvert inherit | 2 |
| outline-style | Sets the style of an outline | none dotted dashed solid double groove ridge inset outset inherit | 2 |
| outline-width | Sets the width of an outline | thin medium thick lengthinherit | 2 |

