HTML | DOM Style borderLeftWidth Property

The DOM Style borderLeftWidth property is used to set or return the width of the left border of an element.

Syntax:

  • To get the borderLeftWidth Property
    object.style.borderLeftWidth
  • To set the borderLeftWidth Property
    object.style.borderLeftWidth = "thin | medium | thick | length |
    initial | inherit"

Property Values:

  1. thin: This is used to define a thin left border.

    Example-1:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
          DOM Style BorderLeftWidth
        </title>
      
        <style>
            .elem {
                padding: 10px;
                border-style: solid;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderLeftWidth
        </b>
        <p class="elem">
            GeeksforGeeks is a computer science
          portal with a huge variety of well written and
          explained computer science and programming
          articles, quizzes and interview questions.
        </p>
        <button onclick="changeWidth()">
          Change BorderLeftWidth
        </button>
      
        <!-- Script to change BorderLeftWidth -->
        <script>
            function changeWidth() {
                elem = document.querySelector('.elem');
                elem.style.borderLeftWidth = 'thin';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    thin-before

    After clicking the button:

    thin-after

  2. medium: This is used to define a medium left border. This is the default value.

    Example-2:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
          DOM Style BorderLeftWidth
        </title>
        <style>
            .elem {
                padding: 10px;
                border-style: solid;
                border-left-width: thin;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderLeftWidth
        </b>
        <p class="elem">
            GeeksforGeeks is a computer science
          portal with a huge variety of well
          written and explained computer 
          science and programming articles, 
          quizzes and interview questions.
        </p>
        <button onclick="changeWidth()">
          Change BorderLeftWidth
        </button>
      
        <!-- Script to change BorderLeftWidth -->
        <script>
            function changeWidth() {
                elem = document.querySelector('.elem');
                elem.style.borderLeftWidth = 'medium';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    medium-before

    After clicking the button:

    medium-after

  3. thick: This is used to define a thick left border.

    Example-3:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
          DOM Style BorderLeftWidth
        </title>
      
        <style>
            .elem {
                padding: 10px;
                border-style: solid;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderLeftWidth
        </b>
        <p class="elem">
          GeeksforGeeks is a computer science
          portal with a huge variety of well
          written and explained computer science
          and programming articles, quizzes 
          and interview questions.
        </p>
        <button onclick="changeWidth()">
          Change BorderLeftWidth
        </button>
      
        <!-- Script to change BorderLeftWidth -->
        <script>
            function changeWidth() {
                elem = document.querySelector('.elem');
                elem.style.borderLeftWidth = 'thick';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    thick-before

    After clicking the button:

    thick-after

  4. length: This is used to define the left border width in terms of length units.

    Example-4:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
          DOM Style BorderLeftWidth
        </title>
      
        <style>
            .elem {
                padding: 10px;
                border-style: solid;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderLeftWidth
        </b>
        <p class="elem">
          GeeksforGeeks is a computer science portal
          with a huge variety of well written and 
          explained computer science and programming
          articles, quizzes and interview questions.
        </p>
        <button onclick="changeWidth()">
          Change BorderLeftWidth
        </button>
      
        <!-- Script to change BorderLeftWidth -->
        <script>
            function changeWidth() {
                elem = document.querySelector('.elem');
                elem.style.borderLeftWidth = '10px';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    length-before

    After clicking the button:

    length-after

  5. initial: This is used to set this property to its default value.

    Example-5:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
          DOM Style BorderLeftWidth
        </title>
      
        <style>
            .elem {
                padding: 10px;
                border-style: solid;
                border-left-width: 15px;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderLeftWidth
        </b>
        <p class="elem">
            GeeksforGeeks is a computer science portal
          with a huge variety of well written and explained
          computer science and programming articles, quizzes
          and interview questions.
        </p>
        <button onclick="changeWidth()">
          Change BorderLeftWidth
        </button>
      
        <!-- Script to change BorderLeftWidth -->
        <script>
            function changeWidth() {
                elem = document.querySelector('.elem');
                elem.style.borderLeftWidth = 'initial';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    initial-before

    After clicking the button:

    initial-after

  6. inherit: This inherits the property from its parent.

    Example-6:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
          DOM Style BorderLeftWidth
        </title>
      
        <style>
            #parent {
                padding: 10px;
                border-style: solid;
                border-left-width: 15px;
            }
              
            .elem {
                padding: 10px;
                border-style: solid;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderLeftWidth
        </b>
        <br>
        <br>
        <div id="parent">
            <p class="elem">
                GeeksforGeeks is a computer science
              portal with a huge variety of well
              written and explained computer science
              and programming articles, quizzes and
              interview questions.
            </p>
        </div>
        <br>
        <button onclick="changeWidth()">
          Change BorderLeftWidth
        </button>
      
        <!-- Script to change BorderLeftWidth -->
        <script>
            function changeWidth() {
                elem = document.querySelector('.elem');
                elem.style.borderLeftWidth = 'inherit';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    inherit-before

    After clicking the button:

    inherit-after

  7. Supported Browsers: The browser supported by borderLeftWidth property are listed below:

    • Google Chrome
    • Internet Explorer
    • Firefox
    • Opera
    • Apple Safari


    My Personal Notes arrow_drop_up

    Technical Writer Lets have an update

    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.