HTML Images

The <img> tag is used to define HTML images. Images are used to improve the design and the appearance of a web page.

HTML Images Syntax

<img src=”image-url”>

The src attribute specifies the URL of the image.

HTML Images Example

<img src=”my_image.jpg”>

The alt Attribute

The alt attribute provides an alternate text for an image, if the user for some reason cannot view it. The text should be a short description of the image.

<img src=”my_image.jpg” alt=”Profile Image”>

Image Sizes

The width and height attributes are used to define the image size. Also the style attribute can be used to specify the width and height of an image.

<img src=”my_image.jpg” alt=”Profile Image” width=”500″ height=”500″>
<img src=”my_image.jpg” alt=”Profile Image” style=”width:500px;height:500px;”>

Image as a Link

Images can be used as links. To use an image as a link, put the <img> tag inside the <a> tag.

<a href=””>
<img src=”html-img.jpg” alt=”HTML tutorial” style=”width:50px;height:50px;border:0;”>