HTML | DOM Style borderTopLeftRadius Property

The DOM Style borderTopLeftRadius property is used to set or return the radius of the top left border of an element.

Syntax:

  • To get the borderTopLeftRadius Property
    object.style.borderTopLeftRadius
  • To set the borderTopLeftRadius Property
    object.style.borderTopLeftRadius = "length | percentage | 
    initial | inherit"

Property Values:

  1. length: This is used to define the radius in fixed length units. Two values may be used to specify the radii of the quarter ellipse, the first value being the horizontal radius and the second value being the vertical radius.

    Example-1: Using one value to specify the radius.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
            DOM Style BorderTopLeftRadius
        </title>
      
        <style>
            .elem {
                padding: 10px;
                border-style: solid;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderTopLeftRadius
        </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="changeRadius()">
          Change borderTopLeftRadius
        </button>
      
        <!-- Script to change borderTopLeftRadius -->
        <script>
            function changeRadius() {
                elem = document.querySelector('.elem');
                elem.style.borderTopLeftRadius = '30px';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    length-one-before

    After clicking the button:

    length-one-after

    Example-2: Using two values to specify the radius.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
            DOM Style BorderTopLeftRadius
        </title>
        <style>
            .elem {
                padding: 10px;
                border-style: solid;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderTopLeftRadius
        </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="changeRadius()">
          Change borderTopLeftRadius
        </button>
      
        <!-- Script to change borderTopLeftRadius -->
        <script>
            function changeRadius() {
                elem = document.querySelector('.elem');
                elem.style.borderTopLeftRadius = '30px 60px';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    length-two-before

    After clicking the button:

    length-two-after

  2. percentage: This is used to define the radius in percentage units. Two values may be used to specify the radii of the quarter ellipse, the first value being the horizontal radius which is the percentage of the width of the border box, and the second value being the vertical radius which is the percentage of the height of border-box.

    Example-3: Using one value to specify the radius.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
            DOM Style BorderTopLeftRadius
        </title>
        <style>
            .elem {
                padding: 10px;
                border-style: solid;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderTopLeftRadius
        </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="changeRadius()">
          Change borderTopLeftRadius
        </button>
      
        <!-- Script to change borderTopLeftRadius -->
        <script>
            function changeRadius() {
                elem = document.querySelector('.elem');
                elem.style.borderTopLeftRadius = '20%';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    percentage-one-before

    After clicking the button:

    percentage-one-after

    Example-4: Using two values to specify the radius.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
            DOM Style BorderTopLeftRadius
        </title>
        <style>
            .elem {
                padding: 10px;
                border-style: solid;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderTopLeftRadius
        </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="changeRadius()">
          Change borderTopLeftRadius
        </button>
      
        <!-- Script to change borderTopLeftRadius -->
        <script>
            function changeRadius() {
                elem = document.querySelector('.elem');
                elem.style.borderTopLeftRadius = '30% 90%';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    percentage-two-before

    After clicking the button:

    percentage-two-after

  3. 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 BorderTopLeftRadius
        </title>
        <style>
            .elem {
                padding: 10px;
                border-style: solid;
                border-top-left-radius: 30px;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderTopLeftRadius
        </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="changeRadius()">
          Change borderTopLeftRadius
        </button>
      
        <!-- Script to change borderTopLeftRadius -->
        <script>
            function changeRadius() {
                elem = document.querySelector('.elem');
                elem.style.borderTopLeftRadius = 'initial';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    initial-before

    After clicking the button:

    initial-after

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

    Example:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
            DOM Style BorderTopLeftRadius
        </title>
        <style>
            #parent {
                padding: 10px;
                border-style: solid;
                /* Setting the borderTopLeftRadius of the parent */
                border-top-left-radius: 30px;
            }
              
            .elem {
                padding: 10px;
                border-style: solid;
            }
        </style>
    </head>
      
    <body>
        <h1 style="color: green">
          GeeksforGeeks
        </h1>
        <b>
          DOM Style BorderTopLeftRadius
        </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="changeRadius()">
          Change borderTopLeftRadius
        </button>
      
        <!-- Script to change borderTopLeftRadius -->
        <script>
            function changeRadius() {
                elem = document.querySelector('.elem');
                elem.style.borderTopLeftRadius = 'inherit';
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before clicking the button:

    inherit-before

    After clicking the button:

    inherit-after

Supported Browsers: The browser supported by borderTopLeftRadius property are listed below:

  • Google Chrome
  • Internet Explorer 9.0
  • 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.