HTML Code for Inserting an image

Introduction to Inserting an Image in HTML

Inserting an image in HTML is a common task when creating a website or web application. HTML provides a simple and straightforward way to insert images using the <img> tag.

The <img> Tag

The <img> tag is used to embed an image in an HTML page. It is a self-closing tag which means it does not have an end tag. The <img> tag has attributes that specify the source of the image, its width and height, alternative text, and more.

Attributes of the <img> Tag

The most essential attribute of the <img> tag is the 'src' attribute, which specifies the URL of the image. The 'alt' attribute is also important as it provides alternative text for the image, which is displayed if the image cannot be loaded. Other useful attributes include 'width', 'height', 'title', and 'style'.

Example Code

<img src="image.jpg" alt="Description of the image" width="300" height="200">

Go from files to website in seconds.

Start a free trial for 7 days — no credit card required

Get Started for Free