Skip to main content

Command Palette

Search for a command to run...

Working with Images in HTML

Published
1 min read
Working with Images in HTML
B
Software Engineer (Backend Engineer) | AI Engineer

To add an image to your HTML page, you can use the <img> tag.

The <img> tag is a self-closing tag, which means you don't need to add a closing tag.

The src attribute specifies the URL of the image file you want to display.

<img src="image.png" />

You can also specify the size of the image using the height and width attributes.

<img src="image.png" width="300" height="300" />

If you want to add alternative text for the image, in case the image cannot be displayed the alternative text will display, you can use the alt attribute.

<img src="image.png" alt="user image" width="300" height="200" />

You can also add a caption or title to the image.

More from this blog

R

RiteChoice23

30 posts

Programming and technical education.