CSS outline pro...LOGIN

CSS outline property

CSS Outlines


An outline is a line drawn around an element, located outside the edge of the border, which can highlight the element.

The outline attribute specifies the style, color and width of the outer border.


CSS outline (outline)

The outline (outline) is a line drawn around the element, located outside the edge of the border, which can highlight the element.

The CSS outline property specifies the style, color, and width of an element's outline.

box_outline.gif

All CSS outline properties

The number in the "CSS" column indicates which CSS version defines the property (CSS1 or CSS2).

AttributeDescriptionValueCSS
outline Set all outer border properties in one statementoutline-color
Outline-style
outline-width
inherit
2
outline-colorSet the color of the outer bordercolor-name
hex-number
rgb-number
invert
inherit
2
outline-styleSet the style of the outer bordernone
dotted
dashed
solid
     double
Groove
ridge
inset
Outset
inherit
2
outline-widthSet the width of the outer borderthin
medium
thick
length
inherit
2

##For usage, please view our css reference manual


##Example


Draw a line around an element

     <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>php中文网(php.cn)</title>
    <style>
        p
        {
            border:1px solid red;
            outline:green dotted thick;
        }
    </style>
</head>

<body>
<p><b>注意:</b> 如果只有一个!DOCTYPE指定IE8支持 outline属性。</p>
</body>
</html>

Run the program and try it


Example

Set the width of the outline

   <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>php中文网(php.cn)</title>
    <style>
        p.one
        {
            border:1px solid red;
            outline-style:solid;
            outline-width:thin;
        }
        p.two
        {
            border:1px solid red;
            outline-style:dotted;
            outline-width:5px;
            outline-color: #99fc58;
        }
    </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>

</body>
</html>
Run the program and try it



Next Section

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style> p.one { border:1px solid red; outline-style:solid; outline-width:thin; } p.two { border:1px solid red; outline-style:dotted; outline-width:5px; outline-color: #99fc58; } </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> </body> </html>
submitReset Code
ChapterCourseware