1. css
  2. /properties
  3. /border-top-left-radius

border-top-left-radius

Definition

border-top-left-radius is a CSS property that sets the radius of the top-left corner of an element's border. The value can be specified in length units (e.g. pixels, ems) or as a percentage of the element's width or height. This property allows you to create rounded corners on the top-left corner of an element, rather than having sharp corners.

Examples

Setting the top-left border radius to 10 pixels:

element {
    border-top-left-radius: 10px;
}

Setting the top-left border radius to 5% of the element's width:

element {
    border-top-left-radius: 5%;
}

Setting the top-left border radius to a combination of length and percentage units:

element {
    border-top-left-radius: 10px 20%;
}

Setting all four border radii at once using the border-radius shorthand property:

element {
    border-radius: 10px 20px 30px 40px;
}

Using different border-radius values for each corner using border-radius shorthand property:

element {
    border-radius: 10px;
}

Using border-top-left-radius in conjunction with other border properties:

element {
    border-top-left-radius: 10px;
    border-top: 2px solid blue;
}

Values

ValueDescription
<length>A valid length value, such as pixels (px), ems (em), or points (pt).
<percentage>A value specified as a percentage of the width or height of the element.
initialSets the border-top-left-radius property to its default value.
inheritInherits the border-top-left-radius value from its parent element.

Best Practices

  • Use consistent units: When specifying the radius value, try to use consistent units throughout your CSS. For example, if you use pixels for one corner, use pixels for all corners.
  • Be mindful of accessibility: Keep in mind that some users may have difficulty distinguishing certain border radii, especially if they have visual impairments. Try to use a combination of radius values and patterns to create borders that are easy to see and understand.
  • Test your border radii: Make sure to test your border radii on different devices and browsers to ensure that they look the way you expect them to. Some radii may appear differently on different screens.
  • Use CSS variables: If you need to use the same border-top-left-radius on multiple elements, you can use CSS variables to make it easier to update the radius in one place.
  • Use the border-radius shorthand property: Instead of using the border-top-left-radius property in conjunction with border-top-right-radius, border-bottom-left-radius, and border-bottom-right-radius, you can use the border-radius shorthand property to set all four corners at once. This makes your code more concise and easier to read.
  • Avoid overusing border-radius: Overuse of border-radius can make a design look cluttered and overwhelming. Use border-radius sparingly and only when necessary to enhance the design.
  • Pay attention to the context: Keep in mind the context in which the element is being used, as certain shapes may be more appropriate for certain situations.
  • Use browser-specific prefixes: Keep in mind that some older browsers may not fully support the latest CSS specifications, so you may need to include browser-specific prefixes for your CSS properties to ensure that they are displayed correctly in all browsers.

Browser Compatibility

ChromeFirefoxSafariInternet ExplorerMicrosoft EdgeOpera
YesYesYesYesYesYes