HTML Images




HTML Images

Last Updated Jul 19, 2015, 07:50:06 PM

Images are the other way of displaying content on the HTML document.

It is possible to include images in HTML documents. This is done using the img HTML element. Here is one simple example:

The src attribute contains the URL to the image to include. The image is included in the document at the point where the img element is located.

HTML Image Example


Try It Now

Image Size - Width and Height

You can use the style attribute to specify the width and height of an image.

Example
Try It Now

The alt Attribute

The img element has an attribute named alt. This attribute gives alternative information about the image used. This information can be displayed if the image cannot be displayed correctly, or read aloud by page readers used by blind people.

The value of the alt attribute is also used by Google and other search engines to find out what your page is about.

Here is an img example with an alt attribute:


Try It Now

The title Attribute

The title attribute in html images gives more explanation about the image or it gives more description about what the image is

Example
Try It Now

The border Attribute

The border attribute sets the border thickness around the image when displayed in the browser. Here is an example:


Try It Now

This example creates a 1-pixel wide border around the image. If you want to have no border, set the border attribute value to 0.



HTML Images as Links

You can use an image as a link by embedding the img element inside an a element. Here is an example:


Try It Now

HTML align Attribute

The img element has an align attribute that defines how the text following the image should wrap around the image. Here is an example:


Try It Now

Note:

align property is deprecated since HTML4.01, Obsolete since HTML5 . Use the vertical-align CSS property instead



Browser Support
Property
Images (Yes) (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)


Practice with Our Interactive Live Code Editor and Take your HTML Skills to the next level

Exercise 1 Exercise 2 Exercise 3 Exercise 4 Exercise 5

Sources and Credits

The source of the content has been referred and updated with Mozilla Foundation and w3C

Last Updated Jul 19, 2015, 07:50:06 PM