THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML <img> border Attribute

❮ HTML <img> tag

Example

An image with a 5 pixels thick border:

<img src="smiley.gif" alt="Smiley face" border="5">
Try it Yourself »

Definition and Usage

The border attribute specifies the width of the border around an image.

Note: An image has no border by default.


Browser Support

Attribute
border Yes Yes Yes Yes Yes

The border attribute is deprecated, but still supported in all major browsers.


Compatibility Notes

The border attribute of <img> is not supported in HTML5. Use CSS instead.

CSS syntax: <img style="border:5px solid black">

CSS Example: image border

In our CSS tutorial you can find more details about the border property.


Syntax

<img border="pixels">

Attribute Values

Value Description
pixels The width of the border, in pixels

❮ HTML <img> tag