CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



border-top-right-radius

The border-top-right-radius property is a CSS property that allows you to set the radius of the top-right corner of an element's border. This property is used to create rounded corners on an element's border, which can be used to create a more visually appealing design.

The border-top-right-radius property is part of the CSS3 specification and is supported by all modern browsers. It is a shorthand property that allows you to set the radius of the top-right corner of an element's border in a single declaration.

Here is the syntax for the border-top-right-radius property:


border-top-right-radius: <length> | <percentage> | initial | inherit;

The value of the border-top-right-radius property can be specified in one of four ways:

  • <length>: Specifies the radius of the top-right corner of the element's border in pixels, ems, or other length units.
  • <percentage>: Specifies the radius of the top-right corner of the element's border as a percentage of the element's width or height.
  • initial: Sets the property to its default value.
  • inherit: Inherits the property from its parent element.

Here are some examples of how to use the border-top-right-radius property:


/* Set the radius of the top-right corner of the element's border to 10 pixels */
border-top-right-radius: 10px;

/* Set the radius of the top-right corner of the element's border to 50% of the element's width */
border-top-right-radius: 50%;

/* Set the radius of the top-right corner of the element's border to 10 pixels and 50% of the element's width */
border-top-right-radius: 10px 50%;

/* Set the radius of all four corners of the element's border to 10 pixels */
border-radius: 10px;

It is important to note that the border-top-right-radius property only affects the top-right corner of an element's border. If you want to set the radius of all four corners of an element's border, you should use the border-radius property instead.

Here is an example of how to use the border-top-right-radius property to create a box with a rounded top-right corner:


<div style="width: 200px; height: 200px; background-color: #ccc; border-top-right-radius: 20px;"></div>

This will create a box with a width and height of 200 pixels, a background color of #ccc, and a top-right corner radius of 20 pixels.

Overall, the border-top-right-radius property is a useful CSS property that allows you to create rounded corners on an element's border. It is easy to use and is supported by all modern browsers.

References

Activity