HTML img Tag | How to add image in website?

Image Tag in HTML

The <img> tag is the image tag in HTML. It insert images in webpages. It is a single tag, i.e., it has no closing tag.

Images are necessary part of writing rich content on the internet. They help in easy reading. They are the face of content on internet, especially on social media.

You can add thumbnail images for social media using meta tags, which we will discuss in meta tag tutorial. Today we will discuss about inserting images within the body of a webpage.

The <img> tag has specified syntax with different attributes to control image behavior. Loot at the syntax below:

Syntax
<img src="location_of_image" alt="info about image" height="px" width="px" />

img Tag Example

img Tag Attributes

Attribute Example Description
src <img src="https://www.hkrhasan.com/static/images/html.png" /> The src attribute in img tag specify the location of the image.
height & width <img src="https://www.hkrhasan.com/static/images/html.png" height="200px" width="300px" /> The width and height attribute controls the dimensions of image in the webpage.
alt <img src="https://www.hkrhasan.com/static/images/html.png" alt="text" /> In alt attribute, you will give brief information about the image.