Deprecated in HTML5. Do not use.

<img border="">
HTML attribute

Attribute of
What does <img border=""> do?
Previously used to define a border on an image element. It has been deprecated and should no longer be used.

The Old Way to Add a Border to an Image

The border attribute was previously used to add a border to an <img> element.

<!-- Do not do this. This is feature deprecated and may not work in all browsers. -->  <img src="/wp-content/uploads/flamingo.jpg" border="25"> 

This way of adding a border is deprecated in HTML5.

The Right Way to Add a Border to an Image

The right way to add a border to an image (or anything else) is to use CSS. The CSS specification provides three different border properties: border-width, border-style, and border-color.

.border {   border-width: 25px;   border-color: red;   border-style: solid; } 
<img src="/wp-content/uploads/flamingo.jpg" class="border"> 

Border Styles

There are several options for border-style.

.small {  max-width: 300px;  margin: 0 15px 15px 0; }  .border {   border-width: 15px;   border-color: red; }  .dotted {   border-style: dotted; }  .dashed {   border-style: dashed; }  .solid {   border-style: solid; }  .double {   border-style: double; }  .groove {   border-style: groove; }  .ridge {   border-style: ridge; }  .inset {   border-style: inset; }  .outset {   border-style: outset; } 
<img src="/wp-content/uploads/flamingo.jpg" class="small border dotted">  <img src="/wp-content/uploads/flamingo.jpg" class="small border dashed">  <img src="/wp-content/uploads/flamingo.jpg" class="small border solid">  <img src="/wp-content/uploads/flamingo.jpg" class="small border double">  <img src="/wp-content/uploads/flamingo.jpg" class="small border groove">  <img src="/wp-content/uploads/flamingo.jpg" class="small border ridge">  <img src="/wp-content/uploads/flamingo.jpg" class="small border inset">  <img src="/wp-content/uploads/flamingo.jpg" class="small border outset"> 

Mix and Match Border Styles

You can use different border styles for each side of an image.

.border {   border-width: 15px;   border-color: red; }  .mixed {   border-style: solid dashed dotted double; }  
<img src="/wp-content/uploads/flamingo.jpg" class="border mixed"> 

Border Shorthand

If you aren't doing anything too particular or weird, you can combine the three different border rules into the single border property`.

.border {  border: 15px solid red; } 
<img src="/wp-content/uploads/flamingo.jpg" class="border"> 

Border Placement and the Box Model

Borders appear inside the margins specified on an element, but outside the padding.

#green-box {  background-color: green;  margin: 0;  padding: 0; }  #border-padding-margin{  margin: 20px;  border: 20px solid red;  padding: 20px;  background-color: yellow; } 
<div id="green-box"> <img src="/wp-content/uploads/flamingo.jpg" id="border-padding-margin"> </div> 

Values of the border Attribute

Value Name Notes
pixels Defined width of the border, in pixels.

All Attributes of img Element

Attribute name Values Notes
height Identifies the intrinsic height of an image file, in CSS pixels.
srcset list of sources Defines multiple sizes of the same image, allowing the browser to select the appropriate image source.
align right
Was previously used to specify the alignment and placement of an image relative to the surrounding text. It has been deprecated and should not be used.
alt text Defines alternate text, which may be presented in place of the image.
border pixels Previously used to define a border on an image element. It has been deprecated and should no longer be used.
controls Toggled media player controls when used in conjunction with the <code>dynsrc</code> attribute. Both attributes are now deprecated.
hspace Previously used to add horizontal space on both side of an image. It is now deprecated.
ismap Identifies an image as a server-side image map. When the containing anchor link is clicked, the coordinates of the mouse will be included in the request.
longdesc Defines a URL at which can be found more information about the image. It was written out of the HTML5 specification, but its status is not quite so clear as other deprecated features.
loop Previously used to specify the number of times a video should play, when used in conjunction with the dynsource attribute. Both attributes have been deprecated.
lowsrc Specified a smaller or lower-quality version of an image.
name Identified the image or provided additional information about it. Deprecated in HTML 4.0 in favor of other attributes.
naturalsizeflag This attribute does nothing. It was once used by a proprietary software system.
nosave Was intended to prevent users from downloading an image. Was never a part of the HTML specification, and not widely implemented.
start fileopen
suppress Used by the now-defunct Netscape browser to suppress the display of image prior to image download completion.
usemap Specifies a client-side image map to be used with the image.
width Indicates the intrinsic width of the image, in CSS pixels.
src Specifies the URL of an image to be displayed.