W3Schools

home HOME

Full Overview

HTML5 Tags

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

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Forum

Helping W3Schools

HTML 5 <img> tag


Definition and Usage

The img element defines an image.


Differences Between HTML 4.01 and HTML 5

The "align", "border", "hspace", and "vspace" attributes of the image element were deprecated in HTML 4.01, and are no longer supported in HTML 5.


Example

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


Attributes

  • 4: indicates if the attribute is defined in HTML 4.01
  • 5: indicates if the attribute is defined in HTML 5
Attribute Value Description 4 5
alt text Defines a short description of the image 4 5
src URL The URL of the image to display 4 5
align top
bottom
middle
left
right
Specifies how to align the image according to surrounding text. Not supported. Use CSS instead 4  
border pixels Defines a border around an image. Not supported. Use CSS instead 4  
height pixels
%
Defines the height of an image 4 5
hspace pixels Defines white space on the left and right side of the image. Not supported. Use CSS instead 4  
ismap URL Defines the image as a server-side image map 4 5
longdesc URL  A URL to a document that contains a long description of the image. Not supported 4  
usemap URL Defines the image as a client-side image map. Look at the <map> and <area> tags to figure out how it works 4 5
vspace pixels Defines white space on the top and bottom of the image. Deprecated. Use styles instead 4 5
width pixels
%
Sets the width of  an image 4 5

Standard Attributes

class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title

For a full description, go to Standard Attributes in HTML 5.

Event Attributes

onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup, onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout, onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload

For a full description, go to Event Attributes in HTML 5.


Try-It-Yourself Demos

Insert images
How to display images in your Web page.

Insert images from different locations
How to display images from another folder or another server in your Web page.

Let the image float
How to let an image float to the left or right of a paragraph.

Adjust an image to different sizes
How to adjust an image to different sizes.

Make a hyperlink of an image
How to use an image as a link.

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





Learn XML with <oXygen/> XML Editor - Free Trial!

oXygen - Probably The World's Best XML Editor   

oXygen helps you learn to define, edit, validate and transform XML documents. Supported technologies include XML Schema, DTD, Relax NG, XSLT, XPath, XQuery, CSS.

Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!

Do you have any XML related questions? Get free answers from the oXygen XML forum and from the video demonstrations.

Download a FREE 30-day trial today!




Jump to: Top of Page or HOME or Printer Friendly Printer friendly page

W3Schools provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2008 by Refsnes Data. All Rights Reserved.

Validate Validate W3C-WAI level A conformance icon W3Schools was converted to XHTML in December 1999