CSS border-top property

Description

CSS border-top property defines the width, style, and color for the top side border of a box. It is a shorthand property of border-top-width, border-top-style, and border-top-color.

Syntax

border-top : border-top-width    border-top-style    border-top-color;

Property values

border-top-width

mediumDefault

medium value represents medium sized border for the top side. thin≤medium≤thick

border-top-width: medium;

thin

thin value defines thin line border for the top side.

border-top-width: thin;

thick

thick value defines a thick line border for the top side.

border-top-width: thick;

+ve length

lenght defines the line width of border for the top side. The used units might be px, in, em, pt.

border-top-width: 10px;

border-top-style

solidDefault

The top border consists of a solid line.

border-top-style: solid;

none

There is no style. In this case, the color and width of top border are also ignored i.e. 0px border.

border-top-style: none;

hidden

It is same as 'none' but resolve to different results for the border-collapse property in tables.

border-top-style: hidden;

dashed

The top border consists of a series of square shaped dashes.

border-top-style: dashed;

dotted

The top border consists of a series of round dots.

border-top-style: dotted;

double

The top border consists of two lines. The total border-top-width equals to the two lines and space between them.

border-top-style: double;

ridge

The content seems to be coming out of the canvas. It is obtained by producing the box-shadow from the two colors that are lighter and darker than the border-color.

The outer side of the top border is darker than the inner side of the top border.

border-top-style: ridge;

groove

The content seems to be going into the canvas. It is obtained by producing the box-shadow from the two colors that are lighter and darker than the border-color.

The inner side of the top border is darker than the outer side of the top border.

border-top-style: groove;

inset

The color of top and left borders is darker than border-color but the color of right and top borders is the same as border-color.

The effect of inset value can be observed in border.

border-top-style: inset;

outset

The color of top and left sides is the same as border-left but the color of right and top sides is darker than border-color.

The effect of outset value can be observed in border.

border-top-style: outset;

border-top-color

currentColorDefault

currentColor keyword represents the same color for the top side border as of text color.

border-top-color: currentColor;

color-name

The following demo represents skyblue color for the top side border.

border-top-color: skyblue;

rgb value

It represents rgb value of a color.

The hexadecimal value of red color for the top side border is given below.

border-top-color: rgb(255,0,0);

hexadecimal value

It represents hexadecimal notation of red color.

The hexadecimal notation of blue color for the top side border is given below.

border-top-color: #0000ff;

Applicable to

See longhand properties

#CSS digger
Was this article helpful?

 
border-top defines border-top-width, border-top-style, and border-top-color.
×

Ctrl+D