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

> Canonical HTML version: https://rocketvalidator.com/html-validation/the-border-attribute-on-the-img-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 `<img>` element is obsolete in HTML5 and should be replaced with CSS.

Older versions of HTML allowed `border` as an attribute directly on `<img>` elements, most commonly set to `0` to remove the blue border that browsers added around images wrapped in links. HTML5 dropped this attribute from the specification. Modern browsers no longer add that default border, so in most cases the attribute can simply be removed.

If you still need to control the border on an image, use CSS instead. You can apply a style directly with the `style` attribute, use a class, or add a rule in your stylesheet.

## HTML examples

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

```html
<a href="/home">
  <img src="logo.png" alt="Logo" border="0">
</a>
```

### Valid: using CSS instead

```html
<a href="/home">
  <img src="logo.png" alt="Logo" style="border: 0;">
</a>
```

Or, with a stylesheet rule:

```html
<style>
  img {
    border: 0;
  }
</style>

<a href="/home">
  <img src="logo.png" alt="Logo">
</a>
```
