English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Complete List of CSS Properties

CSS border-top-Usage and example of width attribute

border-top-The width CSS attribute is used to set the width of the top border of the element. However, in many cases, like  border-widthorborder-topSuch a shorthand CSS attribute is more convenient and preferable to use.

The following table provides usage instructions and version history of this attribute, as well as its usage syntax in JavaScript scripts.

Default value:medium
Applicable to:All elements
Inheritance:No
Animatable:Yes.Please refer to Animation properties.
Version:CSS 1,2,3
JavaScript syntax:object object.style.borderTopWidth="thick"

border-top-The syntax of width

The syntax of this attribute is as follows:

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

The following examples demonstrate how to use the border-top-width attribute.

  p {
   border-style: solid;
   border-top-width: 15px;
  }
Test and see‹/›

Note:You must specify in the border-bottom-width attribute is declared beforeborder-styleAttribute. The element must have a border before the border width can be set, because theborder-styleThe default value of the attribute is none.

Attribute value

The following table describes the value of this attribute.

ValueDescription
thinThin border.
mediumMedium border.
thickThick border.
LengthLength values in units such as px, pt, cm, em, etc. Negative values are not allowed.
initialSet this property to its default value.
inheritIf specified, the associated element adopts its parent element's border-top-The value of the width attribute.

Browser compatibility

border-top-Browser compatibility of the width attribute, the numbers in the table below represent the minimum version number of the browser that supports this attribute; all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 4+

  • Apple Safari 1+

  • Opera 4+

Further reading

See tutorial:CSS Border,CSS3 Border.

Related properties:border,border-width,border-top,border-top-color,
border-top-style.