# The “border” attribute on the “table” element is obsolete. Consider specifying “img { border: 0; }” in CSS instead.

> Canonical HTML version: https://rocketvalidator.com/html-validation/the-border-attribute-on-the-table-element-is-obsolete-consider-specifying-img-border-0-in-css-instead
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `border` attribute on the `<table>` element is obsolete in HTML5 and should be replaced with CSS styling.

The `border` attribute was commonly used in older HTML to add borders to tables. In HTML5, the only valid value for the `border` attribute on a `<table>` is an empty string (`""`) or `"1"`, and even then it's considered obsolete. The validator message mentions `img { border: 0; }` because the `border` attribute was also frequently used on `<img>` elements, but the same principle applies to tables — presentational attributes should be replaced with CSS.

To style table borders, use the CSS `border` property on the `<table>`, `<th>`, and `<td>` elements. The `border-collapse` property is also useful for controlling whether borders are merged or separated.

## HTML Examples

### ❌ Invalid: using the obsolete `border` attribute

```html
<table border="2">
  <tr>
    <td>Cell 1</td>
    <td>Cell 2</td>
  </tr>
</table>
```

### ✅ Valid: using CSS for borders

```html
<style>
  table, td {
    border: 2px solid black;
    border-collapse: collapse;
  }
</style>

<table>
  <tr>
    <td>Cell 1</td>
    <td>Cell 2</td>
  </tr>
</table>
```
