HTML img border Attribute
HTML <img> tag
Definition and Usage
The border attribute specifies the width of the border around an image.
By default, an image will have no border. The border attribute allows set a
border and specify the border width in pixels
Compatibility Notes
The border attribute of the img element was deprecated in HTML 4.01
and is not supported in XHTML 1.0 Strict DTD.
Use CSS instead.
CSS syntax: <img style="border:4px solid black"/>
In our CSS tutorial you can find more details about the
border property.
Syntax
Syntax Example
Attribute Values
Value |
Description |
pixels |
Specifies the border width in pixels |
Browser Support
The attribute is deprecated, but still supported in all major browsers.
Example
Source |
Output |
<img src="demo_img.jpg"
alt="W3Schools example picture"
border="4" />
|
|
Try-It-Yourself Demos
img border
attribute example
Specify the border width of an image.
In CSS: image
border
Specify the border width, style, and color of an image.
HTML <img> tag
|