Fandom

HTML & CSS Wiki

Border

649pages on
this wiki
Add New Page
Comments0 Share

The border property is used in CSS and some special HTML tags. It makes a border around the selected text, making each side the same color, effects, etc. A background-color is not necessary for this property to work, but if you want to specify a specific border for each side of an object, use border-left, border-right, border-top, or border-bottom, to specify a different border for each side. The padding property can also be used to specify the border wrapping around the text.


Values

You can use either thin, medium, thick, or any number in pixels to specify the thickness of the border. You can also use solid, dotted, or dashed as the linetype of the border.


To apply this in an HTML document, use:

<span style="border:thin solid red;">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:5px solid red;
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.