border: ***;

Browser
  • IE
  • Cr
  • Sf
  • Fx
  • O

The border property sets the border of an element.

The border of the table and cells can be specified by applying this property to the TABLE, TD, and TH elements.


table, td, th {
border: 2px red solid;
}

Property Value Explanation
border each value sets width, color, and style

The display examples

When you apply this property to the TABLE, TD, and TH elements.

table, td, th { border: 2px #808080 solid; }

Heading A Heading B
Cell A Cell B

When you apply this property to the TABLE element only.

table { border: 2px #808080 solid; }

Heading A Heading B
Cell A Cell B

When you apply this property to the TD and TH elements.

td, th { border: 2px #808080 solid; }

Heading A Heading B
Cell A Cell B

Example


<html>
<head>
<title>TAG index</title>

<style type="text/css">

table, td, th { border: 2px #0080ff solid; }

</style>

</head>
<body>

<table>
<tr>
<th>Heading A</th>
<th>Heading B</th>
</tr>
<tr>
<td>Cell A</td>
<td>Cell B</td>
</tr>
</table>

</body>
</html>

Output
Heading A Heading B
Cell A Cell B