1. css
  2. /properties
  3. /border-right-style

border-right-style

Definition

The border-right-style property sets the style of an element's right border. This property is used in conjunction with the border-right-color and border-right-width properties to create the overall look of the right border.

Examples

To create a solid red right border with a width of 2 pixels:

border-right: 2px solid red;

To create a double black right border with a width of 3 pixels:

border-right: 3px double black;

To create a dotted blue right border with a width of 1 pixel:

border-right: 1px dotted blue;

To create a dashed green right border with a width of 4 pixels:

border-right: 4px dashed green;

To create a groove-style 3D border with a width of 5 pixels, using the current text color:

border-right: 5px groove currentColor;

To create an inset 3D border with a width of 6 pixels, and the color #ccc:

border-right: 6px inset #ccc;

To remove the border-right:

border-right: none;

Values

ValueDescription
noneNo border is drawn. This is the default value.
hiddenSame as 'none', but the border will still take up space
solidA solid border
doubleA double border
dottedA dotted border
dashedA dashed border
grooveA 3D groove border
ridgeA 3D ridge border
insetA 3D inset border
outsetA 3D outset border

Best Practices

  • Test in multiple browsers: As I mentioned before, different web browsers may interpret the border-right-style property slightly differently, so it's a good idea to test your code in multiple browsers to ensure that it looks the way you expect it to.
  • Be consistent: Make sure you're consistent with your use of the border-right-style property throughout your website. Using different border styles on different parts of your website can create a disjointed and unprofessional look.
  • Use shorthand: The border-right property is a shorthand property that allows you to set the border-right-style, border-right-width, and border-right-color properties in a single line of code. This makes your CSS more concise and easier to read.
  • Avoid overusing borders: Overusing borders can make your website look cluttered and overwhelming. Use borders sparingly, and only when they are necessary to convey important information or create visual interest.
  • Accessibility: Consider accessibility when using borders, keep in mind the color contrast and make sure that the border doesn't create confusion for the users.
  • Mobile-Friendly: Be mindful of the border width, especially when working with responsive designs. Borders that are too wide on small screens can make it difficult to see the content and make it hard for users to interact with the interface.

Browser Compatibility

ChromeFirefoxSafariInternet ExplorerMicrosoft EdgeOpera
YesYesYesYesYesYes