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



border-top-style is a CSS property that sets the style of the top border of an element. The border-top-style property sets the style of an element's top border.


Setting the top border to a solid line:

element {
    border-top-style: solid;

Setting the top border to a dotted line:

element {
    border-top-style: dotted;

Setting the top border to a double line:

element {
    border-top-style: double;

Setting the top border to a groove:

element {
    border-top-style: groove;

Setting the top border to a ridge:

element {
    border-top-style: ridge;

Setting the top border to a inset:

element {
    border-top-style: inset;

Setting the top border to a outset:

element {
    border-top-style: outset;

Setting the top border to none:

element {
    border-top-style: none;


noneNo border is drawn.
solidA single solid line is drawn.
dottedA series of round dots are drawn.
dashedA series of short dashes are drawn.
doubleTwo parallel solid lines are drawn.
grooveA 3D groove is drawn.
ridgeA 3D ridge is drawn.
insetA 3D inset is drawn.
outsetA 3D outset is drawn.
initialSets the border-top-style property to its default value.
inheritInherits the border-top-style value from its parent element.

Best practices

  • Use consistent styles: When specifying the border style, try to use consistent styles throughout your CSS. For example, if you use solid style for one element, use solid style for all similar elements.
  • Be mindful of accessibility: Keep in mind that some users may have difficulty distinguishing certain border styles, especially if they have visual impairments. Try to use a combination of styles and patterns to create borders that are easy to see and understand.
  • Test your border styles: Make sure to test your border styles on different devices and browsers to ensure that they look the way you expect them to. Some styles may appear differently on different screens.
  • Use CSS variables: If you need to use the same border-top-style on multiple elements, you can use CSS variables to make it easier to update the style in one place.
  • Use the border-top shorthand property: Instead of using the border-top-style property in conjunction with border-top-color and border-top-width, you can use the border-top shorthand property to set all three properties at once. This makes your code more concise and easier to read.
  • Avoid overusing border-style: Overuse of border-style can make a design look cluttered and overwhelming. Use border-style 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 styles 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.
  • Use border-top-style in combination with other border properties: For example, when creating a button with certain style, you can use border-top-style along with border-top-color and border-top-width to create a complete button style.
  • Be aware of the impact of border-style on layout: Keep in mind that the border-style property can affect the layout of an element, especially when it's used in combination with other layout properties such as width and height.

Browser Compatibility

ChromeFirefoxSafariInternet ExplorerMicrosoft EdgeOpera