IMG Tag in HTML with Example: A Complete Beginner’s Guide

Logan Jul 13, 2026

The tag is a fundamental element in HTML, used to embed images into web pages. It's an essential tool for breaking up text and adding visual content to your site, enhancing user experience and engagement.

Harnessing the Power of the <img> Tag in HTML
Harnessing the Power of the <img> Tag in HTML

In this guide, we'll delve into the tag, exploring its attributes, usage, and best practices. We'll also provide practical examples to help you master this essential HTML element.

Embedding Images in HTML using <img>
Embedding Images in HTML using <img>

Understanding the Tag

The basic syntax of the tag is simple. It looks like this: alternative text. Here's a breakdown:

Commonly Used HTML Tags with Examples - DataFlair
Commonly Used HTML Tags with Examples - DataFlair

The "src" attribute specifies the URL of the image, while "alt" provides alternative text for users who can't view the image. It's crucial for accessibility and SEO.

Basic Tag Usage

HTML TAG
HTML TAG

Here's a simple example:

A description of the image. This will display "image.jpg" from "https://example.com" with the alt text "A description of the image".

Responsive Images with the Tag

10 Essential HTML Tags Every Developer Should Know"
10 Essential HTML Tags Every Developer Should Know"

Responsiveness is key in modern web design. The tag can contribute to this with the "srcset" attribute:

. This displays "small.jpg" on standard screens and "large.jpg" on high-resolution (Retina) displays.

Advanced Tag Techniques

About HTML tags
About HTML tags

Beyond basic usage, the tag offers more advanced features.

costrettoffset and sizes

🏷️ HTML Tags Cheat Sheet | Essential Tags Every Beginner Should Know
🏷️ HTML Tags Cheat Sheet | Essential Tags Every Beginner Should Know
HTML Tags — List of all HTML Tags with Examples TutorialBrain
HTML Tags — List of all HTML Tags with Examples TutorialBrain
the ultimate guide to creating and formating tags
the ultimate guide to creating and formating tags
HTML Heading Tag Example
HTML Heading Tag Example
Saidul (@saidul_dev) on X
Saidul (@saidul_dev) on X
10 Basic HTML Tags for Bloggers: One Stop Shopping!
10 Basic HTML Tags for Bloggers: One Stop Shopping!
What are HTML Tags? List of common HTML Tags
What are HTML Tags? List of common HTML Tags
HTML TAGS
HTML TAGS
List of HTML Tags
List of HTML Tags
Title: HTML Semantic vs Non-Semantic Tags – Guide by RajNandani
Title: HTML Semantic vs Non-Semantic Tags – Guide by RajNandani
List of HTML TAGS
List of HTML TAGS
HTML tags are arranged in the following manner
HTML tags are arranged in the following manner
887 reactions · 135 shares | HTML5 Tags information 2026. #coding #webdevelopment✨ #htmlcssjavascript #programming | Premi Coding | Facebook
887 reactions · 135 shares | HTML5 Tags information 2026. #coding #webdevelopment✨ #htmlcssjavascript #programming | Premi Coding | Facebook
Essential HTML Tags Every Web Developer Needs! 🏷️
Essential HTML Tags Every Web Developer Needs! 🏷️
🔥 HTML Heading Tags Explained (H1 to H6) with Examples | Complete HTML Tutorial for Beginners
🔥 HTML Heading Tags Explained (H1 to H6) with Examples | Complete HTML Tutorial for Beginners
the list of html tags for different types of webpages and pages, with text overlaiding them
the list of html tags for different types of webpages and pages, with text overlaiding them
HTML video tag
HTML video tag
HTML Tag Flashcards
HTML Tag Flashcards
Images in HTML
Images in HTML
12 hot HTML tags to use right now
12 hot HTML tags to use right now

These attributes help control how images are displayed on different devices and viewport sizes:

. This displays "image.jpg" on standard screens and "image@2x.jpg" on high-resolution displays, adjusting the image size based on the viewport width.

Picture Element

The element offers even more control over which image to display based on the user's device and viewport size:

<picture>
  <source srcset="image@2x.jpg" media="(min-width: 800px)">
  <img src="image.jpg">
</picture>
This displays "image@2x.jpg" on screens larger than 800 pixels and "image.jpg" on smaller screens.

mastering the tag opens up a world of possibilities for enhancing your web pages with visual content. From simple image insertion to complex responsive designs, the tag is your key to delivering visually engaging web experiences.