Previous Next

HTML Images

A web page's appearance and layout can be improved by incorporating images. Images are shown in HTML by using the <img> tag.

Example:

<img src="html_pic.jpg" alt="html image">

Output

html image output

Image src Attribute

The src attribute is an obligatory attribute for the <img> tag. In HTML, the src attribute defines the location of the image file that the browser is to render.

Example:

 <img src="html_image_src_attribute.png">

output

image src Attribute output

Image alt Attribute

In HTML, alt attribute is added in the <img> tag to provide alternative text to the image. In case of not being able to load the image file, the image will be displayed as a picture is replaced with this text.

Example:

<img src="html_pic.jpg" alt="html image">

output

image alt Attribute output

Image Width and Height

The src attribute is a mandatory attribute of the tag. In HTML, the src attribute indicates the location of the image file that the browser should show.

Example:

<img src="html_pic.jpg" alt="html image" width="500" height="360">
Previous Next