HTML img tag

## HTML Reference

HTML by Alphabet HTML by Function HTML Global Attributes HTML Events HTML Canvas HTML Audio/Video HTML Doctypes HTML Colornames HTML Colorpicker HTML Colormixer HTML Character Sets HTML ASCII HTML ISO-8859-1 HTML Symbols HTML URL Encode HTML Lang Codes HTTP Messages HTTP Methods Keyboard Shortcuts

## HTML Tags

<!--> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <command> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <head> <header> <h1> - <h6> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <keygen> <label> <legend> <li> <link> <map> <mark> <menu> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <table> <tbody> <td> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>

# HTML <img> Tag

« HTML Reference
<input> Tag »

## Example

How to insert an image:

<img src="smiley.gif" alt="Smiley face" height="42" width="42">
Try it yourself »
(more examples at the bottom of this page)

## Browser Support

The <img> tag is supported in all major browsers.

## Definition and Usage

The <img> tag defines an image in an HTML page.

The <img> tag has two required attributes: src and alt.

Note: Images are not technically inserted into an HTML page, images are linked to HTML pages. The <img> tag creates a holding space for the referenced image.

Tip: To link an image to another document, simply nest the <img> tag inside <a> tags.

## Differences Between HTML 4.01 and HTML5

The following attributes: align, border, hspace, longdesc, and vspace is not supported in HTML5.

The following attributes: align, border, hspace, and vspace are deprecated in HTML 4.01.

## Differences Between HTML and XHTML

In HTML the <img> tag has no end tag.

In XHTML the <img> tag must be properly closed.

## Attributes

New : New in HTML5.

Attribute | Value | Description
--- | --- | ---
align | top bottom middle left right | Not supported in HTML5. Deprecated in HTML 4.01. Specifies the alignment of an image according to surrounding elements
alt | text | Specifies an alternate text for an image
border | pixels | Not supported in HTML5. Deprecated in HTML 4.01. Specifies the width of the border around an image
crossoriginNew | anonymous use-credentials | Allow images from third-party sites that allow cross-origin access to be used with canvas
height | pixels | Specifies the height of an image
hspace | pixels | Not supported in HTML5. Deprecated in HTML 4.01. Specifies the whitespace on left and right side of an image
ismap | ismap | Specifies an image as a server-side image-map
longdesc | URL | Not supported in HTML5. Specifies the URL to a document that contains a long description of an image
src | URL | Specifies the URL of an image
usemap | #mapname | Specifies an image as a client-side image-map
vspace | pixels | Not supported in HTML5. Deprecated in HTML 4.01. Specifies the whitespace on top and bottom of an image
width | pixels | Specifies the width of an image

## Global Attributes

The <img> tag also supports the Global Attributes in HTML.

## Event Attributes

The <img> tag also supports the Event Attributes in HTML.

## Try it Yourself - Examples

Insert images from different locations
How to insert images from another folder or from another web site.

Make a hyperlink of an image
How to add a hyperlink to an image.

Create an image map
How to create an image map, with clickable regions. Each region is a hyperlink.

## Related Pages

HTML tutorial: HTML Images

HTML DOM reference: Image object

« HTML Reference
<input> Tag »

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE