Skip to main content
HTML Validation

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

About This HTML Issue

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

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

Valid: using CSS instead

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

Or, with a stylesheet rule:

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

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

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
$7 / 7 days

Pro Trial

Full Pro access. Cancel anytime.

Start Pro Trial →

Join teams across 40+ countries