Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM Style borderTopRightRadius Property

  • Difficulty Level : Basic
  • Last Updated : 30 Jul, 2019

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

Syntax:

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

Property Values:

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




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

    Output:



    Before clicking the button:

    fixed-one-before

    After clicking the button:

    fixed-one-after

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




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

    Output:

    Before clicking the button:

    fixed-two-before



    After clicking the button:

    fixed-two-after

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




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

    Output:

    Before clicking the button:

    percentage-one-before

    After clicking the button:

    percentage-one-after

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




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

    Output:



    Before clicking the button:

    percentage-two-before

    After clicking the button:

    percentage-two-after

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

    Example-5:




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

    Output:

    Before clicking the button:

    initial-before

    After clicking the button:

    initial-after



  • inherit: This inherits the property from its parent.

    Example-6:




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

    Output:

    Before clicking the button:

    inherit-before

    After clicking the button:

    inherit-after

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

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

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




My Personal Notes arrow_drop_up
Recommended Articles
Page :