HTML <table> borderAttribute

HTML table 标签参考手册HTML <table> Tag

Examples

The following HTML table will display a border around the table cells:

<table border="1">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the border attribute.


Definition and Usage

The border attribute specifies whether a border should be displayed around the table cells.

The value "1" indicates that a border should be displayed, and the table is not used for layout purposes.

Note: This attribute is deprecated. The table element should use CSS to customize styles. The CSS properties border, border-color, border-width, and border-style can achieve the same effect.


Differences Between HTML 4.01 and HTML5

In HTML5, the border attribute is only used to indicate whether the table is used for layout purposes, and only the attribute values "" or "1" are allowed.


Syntax

<table border="1">

Attribute Values

Value Description
"" No border around the table cells (the table can be used for layout purposes).
"1" Adds a border around the table cells (the table is not used for layout purposes).


HTML table 标签参考手册HTML <table> Tag Other Extensions