CSS | outline-width Property

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.

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;
    
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <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>

    chevron_right

    
    

    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;
    
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <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>

    chevron_right

    
    

    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;
    
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!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>

    chevron_right

    
    

    Output:

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

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!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>

    chevron_right

    
    

    Output:

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

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <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>

    chevron_right

    
    

    Output:

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

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!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>                 

    chevron_right

    
    

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

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.