CSS border-top-width property

Definition and usage

The border-top-width property sets the width of the top border of the element.

Only effective when the border style is not none. If the border style is none, the border width will actually reset to 0. Negative length values are not allowed.

Note:Always declare the border-style property before the border-top-width property. The element must have a border to change its border width.

See also:

CSS Tutorial:CSS Borders

CSS Reference Manual:border-top property

HTML DOM Reference Manual:borderTopWidth property

Example

Set the width of the top border:

p
  {
  border-style:solid;
  border-top-width:15px;
  }

Try it yourself

CSS syntax

border-top-width: medium|thin|thick|length|initial|inherit;

Property value

Value Description
thin Define a thin top border.
medium Default value. Defines a medium top border.
thick Define a thick top border.
length Allows you to customize the width of the top border.
inherit Specifies that the border width should be inherited from the parent element.

Technical details

Default value: medium
Inheritance: no
Version: CSS1
JavaScript syntax: object.style.borderTopWidth="thick"

More examples

Setting the width of the top border
This example demonstrates how to set the width of the top border.

Browser support

The numbers in the table indicate the first browser version that fully supports this property.

Chrome IE / Edge Firefox Safari Opera
1.0 4.0 1.0 1.0 3.5

Note:Browsers with IE7 and earlier versions do not support the value "inherit". IE8 requires !DOCTYPE. IE9 supports "inherit".