Let us start with a quick minimum example:
<img src="turtleneck-sweater.jpeg" />
And let us also have a look at more extended example:
<img src="turtleneck-sweater.jpeg" alt="Photograph of a Turtleneck Sweater" title="Photograph of a Turtleneck Sweater" />
Images are normally stored in external files. To place an image into an HTML source, use the
img tag with the
src attribute containing the URL of the image file. To support browsers that cannot render images, you can provide the
alt attribute with a textual description of the image. To provide a tooltip to the image, use the
The space before the
/> in the examples is there on purpose. Some older browsers behave strangely if the space is omitted.
Per default, images are placed inline to their surroundings. To place the image as a block or float instead, you can use Cascading Style Sheets.
The HTML specification requires that all images have an
alt attribute. This is commonly known as alt text. Images can be split in to two categories:
Decorative images should have empty alt text, i.e.
alt="". Images used as bullets may use an asterisk,
All other images should have meaningful alt text. Alt text is not a description of the image, use the
title attribute for short descriptions. Alt text is something that will be read instead of the image. For example,
<img src="company_logo.gif" alt=""> makes the best widgets in the world.
The alt text should be the company's name not the ever popular 'Our logo', which would give the sentence 'Our logo makes the best widgets in the world.' when read in a text only browser.
alt attribute stands for alternate which non-graphic-capable browsers (such as Lynx) may use to better enable its user to understand the purpose of the image. Some older browsers incorrectly use the
alt attribute' tag to produce image tooltips. However, the
title attribute should actually be used for this.
To have an image appear smaller than it is in the external file, use the attributes
height. When only one or the other is specified, images will scale to keep the same overall ratio.
Manage research, learning and skills at defaultlogic.com. Create an account using LinkedIn to manage and organize your omni-channel knowledge. defaultlogic.com is like a shopping cart for information -- helping you to save, discuss and share.