The border-top
property is used in CSS and some special HTML tags. It only makes a border on the top side of the selected text, leaving the other three sides borderless. A background-color
is not necessary for this property to work, but if you want to specify a specific border for the other sides of an object, use border-left
, border-right
, or border-bottom
. If you want to specify a border for the whole area of text, then use border
. The padding
property can also be used to specify the border wrapping around the text.
You can use either thin
, medium
, thick
, or any number in pixels to specify the thickness of the border. Any color will work, either in HTML color codes or valid color names. You can also use solid
or dashed
as the linetype of the border.
To apply this in an HTML document, use:
<span style="border-top:thin solid black;">Border this text</span>
That generates: Border this text
This is a border with the medium
thickness applied: Border this text
This is a border with the thick
thickness applied: Border this text
This is a border with the dashed
linetype applied on a medium
thickness border: Border this text
To apply this in CSS, in the h1
element for example, use:
h1 { background-color:black; color:white; border-top:5px solid black; }