border (HTML attribute)

Spec
Depr. Version
No HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

border="number"

Description

A visible grid doesn’t appear around the table cells by default, which has the potential to make the table quite difficult to read and understand (and bear in mind that this is a very simple example). In order to create structure and order around the data that’s presented, use the border attribute. It applies a border to each cell, and to the table as a whole.

If we change the value of the border attribute, from "1" to "5" for example, the size of the border around the table will change, but the border inside the table—between the table cells—won’t change size, as Figure 1 reflects.

Figure 1. Two tables, one with a border of one pixel, another with a border of five pixels Two tables, one with a border of 1 pixel, another set to 5 pixels

Example

The border for this table is set to "1" pixel:

<table border="1">
  <tr>
    <th>Account Type</th>
    <th>Interest Rate</th>
  </tr>
  <tr>
    <td>Smart</td>
    <td>From 2%</td>
  </tr>
  <tr>
    <td>Young Saver</td>
    <td>From 1.6%</td>
  </tr>
</table>

Value

This attribute takes a numerical value, which reflects a pixel measurement.

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

The border attribute isn’t deprecated—it can be used in a perfectly valid web page. However, although it enjoys full support, it’s preferable not to specify a border. Instead, use CSS to apply the border style and color.

User-contributed notes

There are no comments yet.

Related Products