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

CSS Reference Manual

CSS @rules

Complete List of CSS Properties

CSS border-Usage and examples of top attribute

border-The top CSS property sets the width, style, and color of the element's top border. It sets a single top border attribute (i.e.,border-top-width,border-top-styleas well asborder-top-colorThe shorthand attribute of )

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

Default value:View all properties
Applies to:All elements
Inheritance:None
Animatable:Yes,Please refer to individual properties.Please refer to Animation properties.
Version:CSS 1,2,3
JavaScript syntax:object.style.borderTop="2px solid red"

border-Syntax of top

The syntax of this attribute is as follows:

border-top: [ border-top-width border-top-style border-top-color ] | initial | inherit

The following example demonstrates how to use border-top attribute.

  h1 {
   border-top: 5px solid #ff0000;
  }
  p {
   border-top: 3px dotted #00ff00;
  }
Test and see‹/›

Attribute value

The table below describes the value of this attribute.

ValueDescription
border-top-widthSet the width of the top border of the element.
border-top-styleSet the line style of the top border of the element.
border-top-colorSet the color of the top border of the element.
initialSet this property to its default value.
inheritIf specified, the associated element adopts its parent element's border-The value of the top attribute.

Browser compatibility

border-Browser compatibility of the top 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+

Read more

See tutorial:CSS Border,CSS3 Border.

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