Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

CSS | outline-width Property

  • Last Updated : 09 Aug, 2019

The outline is the line that is created around the specified element outside the border of the element to make the particular distinct and easier to distinguish.

The outline-width Property is used to specify the width of this outline for a specific element.

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

The outline-style property must be declared or used before the outline-width property is used on the desired element. Logically an element must have an outline for which one defines or styles the width.

The outline of an element is displayed around the margin of the element and is not the same as the border property. As the outline is not a part of the element’s dimensions, therefore the element’s width and height properties do not contain the width of the outline.



Syntax:

outline-width: medium|thin|thick|length|initial|inherit;

Property values:

  • medium: This value sets the outline width to default.The width of the outline is thinner than the outline setas thick and thicker than the outline set as thin.
    outline-width: medium;
    




    <html>
       <head>
          <title>
             CSS | outline-width Property
          </title>
       </head>
         
       <body>
          <p style = "outline-width:medium;
                      outline-style:solid;">
             This paragraph has medium outline.
          </p>
       </body>
    </html>

    Output:

  • thin: This value sets the outline width to thin, the outline achieved is thinner than outline specified with width as medium and thick.
    outline-width: thin;
    




    <html>
       <head>
          <title>
             CSS | outline-width Property
          </title>
       </head>
         
       <body>
          <p style = "outline-width:thin; 
                      outline-style:solid;">
             This paragraph has thin outline.
          </p>
       </body>
    </html>

    Output:

  • thick: This value sets the outline width to thick, the outline achieved is thicker than outline specified with width as medium and think.
    outline-width: thick;
    




    <!DOCTYPE html>
    <html>
       <head>
          <title>
             CSS | outline-width Property
          </title>
       </head>
         
       <body>
          <p style = "outline-width:thick; 
                      outline-style:solid;">
             This paragraph has thick outline.
          </p>
       </body>
    </html>

    Output:

  • length: This value is used to define the thickness of the outline.
    outline-width: 15px;
    




    <!DOCTYPE html>
    <html>
       <head>
          <title>
             CSS | outline-width Property
          </title>
       </head>
         
       <body>
          <p style = "outline-width:15px; 
                      outline-style:solid;">
             This paragraph has 15px outline.
          </p>
       </body>
    </html>

    Output:

  • initial: This value sets the outline -width to its default value.
    outline-width: initial;
    




    <html>
       <head>
          <title>
             CSS | outline-width Property
          </title>
       </head>
         
       <body>
          <p style = "outline-width:initial; 
                      outline-style:solid;">
             This paragraph has initial outline.
          </p>
       </body>
    </html>

    Output:

  • inherit: This value inherits the specifications of outline-width property of parent.
    outline-width: inherit;
    




    <!DOCTYPE html>
    <html>
    <head>
        <title>
            CSS | outline-width Property
        </title>
    </head>
          
    <body>
        <p style = "outline-width:medium; 
                     outline-style:solid;">
            This paragraph has medium outline.
        </p>
          
        <p style = "outline-width:thin; 
                    outline-style:solid;">
            This paragraph has thin outline.
        </p>
        <br>
          
        <p style = "outline-width:thick; 
                    outline-style:solid;">
            This paragraph has thick outline.
        </p>
        <br>
          
        <p style = "outline-width:15px; 
                    outline-style:solid;">
            This text has an outline of 15px.
        </p>
        <br><br
        <p style = "outline-width:initial; 
                    outline-style:solid;">
            This text has an outline of default
            type set by initial
        </p>
          
    </body>
    </html>                    

Supported Browsers: The browser supported by CSS | outline-width Property are listed below:

  • Google Chrome 1.0
  • Internet Explorer 8.0
  • Firebox 1.5
  • Opera 7.0
  • Safari 1.2



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!