W3Schools.com

HTML5 <img> Tag

Example

How to insert an image:

<img src="angry.gif" alt="Angry face" />

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

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 layout attributes: align, border, hspace, and vspace were deprecated in HTML 4.01, and are not supported in HTML5.


Attributes

Attribute Value Description
src URL Required. Specifies the URL of an image
alt text Required. Specifies an alternate text for an image
height pixels Specifies the height of an image
ismap ismap  Specifies an image as a server-side image-map
usemap #mapname Specifies an image as a client-side image-map
width pixels Specifies the width of an image

Global Attributes

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


Event Attributes

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


WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE