HTML border Attribute
The obsolete HTML border attribute was historically used to request or control a visible border around certain HTML elements, including tables, images, and embedded content.
border attribute is obsolete and should not be used to style modern HTML. Use CSS border properties instead.
Historical Syntax
The border attribute was added directly to an HTML element. On a table, a numeric value could be used to request a visible border:
<table border="1">
<tr>
<td>Table content</td>
</tr>
</table>
The meaning and effect of the attribute varied depending on the element where it was used. On older webpages, it was also commonly used with images to control the border displayed around an image, particularly when the image was inside a hyperlink.
Historical Elements
The border attribute was historically associated with several elements where borders were part of the element's presentation.
| Element | Historical Purpose |
|---|---|
<table> |
Requested or controlled the display of borders around a table and its cells. |
<img> |
Controlled the border around an image. |
<object> |
Controlled the border around embedded object content. |
Historical Use
The border attribute provided an early way to add borders before CSS became the standard method for controlling webpage presentation. It was particularly common on tables, where a border helped make rows and cells visually distinct.
Older browsers could also display a border around linked images. Authors sometimes used the border attribute on an <img> element to remove or change that visual border.
Why It Became Obsolete
The presentational use of the border attribute mixed visual styling with HTML structure. CSS provides dedicated properties for controlling border width, style, color, and the individual sides of an element.
Moving border presentation to CSS also makes styling easier to reuse and maintain because the same rule can be applied to many elements without repeating presentational attributes throughout the HTML.
Modern Alternative
Use CSS border properties to control the appearance of borders in modern webpages. The border shorthand property can define the border width, style, and color in a single declaration.
Historical HTML
<table border="1">
<tr>
<th>Product</th>
<th>Price</th>
</tr>
<tr>
<td>Garden Gloves</td>
<td>$12.00</td>
</tr>
</table>
Modern HTML and CSS
<table class="bordered-table">
<tr>
<th>Product</th>
<th>Price</th>
</tr>
<tr>
<td>Garden Gloves</td>
<td>$12.00</td>
</tr>
</table>
<style>
.bordered-table,
.bordered-table th,
.bordered-table td {
border: 1px solid #333;
}
.bordered-table {
border-collapse: collapse;
}
</style>
The CSS border property controls the border itself, while border-collapse determines whether adjacent table cell borders remain separate or are combined into a single border.
Learn More About CSS Borders
The CSS tutorials provide more information about creating and controlling borders:
- CSS Borders - Learn how to control an element's border width, style, and color with CSS.
- CSS Styling Tables - Learn how to style tables and table cells with CSS.
Legacy Browser Support
The obsolete presentational uses of the border attribute were widely recognized by older browsers. The exact visual result depended on the element, the attribute value, and the browser's default rendering behavior.
Some browsers may continue to recognize historical uses for compatibility with older webpages. Browser recognition does not make these presentational uses valid modern HTML, and CSS should be used when a border is required.
For additional information about historical browser compatibility, visit Can I Use? . Search for the HTML element or attribute you want to check. Search results can include related HTML features, element attributes, APIs, and other technologies, so select the result that most closely matches the legacy feature you are researching.
Related Attributes
Other obsolete HTML attributes historically used to control borders, spacing, and table presentation include:
bordercolor- Historically used to specify a border color.cellpadding- Historically used to control space inside table cells.cellspacing- Historically used to control space between table cells.frame- Historically used to control which outer borders of a table were displayed.rules- Historically used to control borders between rows and columns in a table.
Specifications
Presentational uses of the border attribute are obsolete in modern HTML. Borders should be styled with CSS. See the WHATWG HTML Living Standard for information about obsolete and non-conforming features.
