TGViewer
Web Development Web Development @webdevcoursefree ยท 79.6K subscribers
Post #4084 537
๐ŸŒ Web Development Roadmap โ€” Part 17

HTML Images โ€” <img> Tag

Images make webpages more visual and engaging. HTML provides the <img> element to display images.

1. Adding an Image

<img src="photo.jpg" alt="A beautiful landscape">


Unlike elements such as <p>, <img> does not need a closing tag.

2. The src Attribute

src stands for source.

It tells the browser where the image is located.

<img src="images/profile.jpg" alt="Profile photo">


The browser follows the path:

HTML
โ†“
src="images/profile.jpg"
โ†“
images folder
โ†“
http://profile.jpg
โ†“
Display image


3. The alt Attribute

alt provides alternative text describing the image.

<img src="profile.jpg" alt="Profile photo">


It is important for accessibility and can also be displayed if the image cannot be loaded.

A good alt describes the actual image:

<img src="dog.jpg" alt="Golden retriever sitting in a park">


Avoid unnecessary descriptions such as:

alt="image"


4. Images Inside Folders

Suppose your project looks like:

my-website/
โ”œโ”€โ”€ http://index.html
โ”œโ”€โ”€ http://style.css
โ””โ”€โ”€ images/
โ”œโ”€โ”€ http://logo.png
โ””โ”€โ”€ http://profile.jpg


You can write:

<img src="images/logo.png" alt="Company logo">


5. Image Dimensions

You can specify dimensions using width and height attributes:

<img
src="profile.jpg"
alt="Profile photo"
width="300"
height="300">


However, modern websites commonly use CSS to control presentation and responsive sizing.

6. Absolute vs Relative Image Paths

Relative path:

<img src="images/photo.jpg" alt="Photo">


This refers to a file within your project.

An external image can use a full URL:

<img
src="https://example.com/photo.jpg"
alt="Example photo">


For real projects, images are often hosted as part of your application or through an image/CDN service.

7. Images as Links

You can place an image inside an anchor element:

<a href="https://example.com">
<img src="logo.png" alt="Example website">
</a>


Now clicking the image follows the link.

8. Decorative Images

Not every image provides meaningful information.

For a purely decorative image, an empty alt is appropriate:

<img src="decorative-line.png" alt="">


This tells assistive technologies that the image can be ignored.

9. Common Image Formats

You will commonly encounter:

JPEG / JPG โ†’ Photos
PNG โ†’ Transparency and graphics
SVG โ†’ Logos and scalable graphics
WebP โ†’ Modern web images
AVIF โ†’ Modern, highly compressed images
GIF โ†’ Simple animations

The appropriate format depends on the type of image and performance requirements.

10. Complete Example

<!DOCTYPE html>

<html>
<head>
<title>My Portfolio</title>
</head>

<body>

<h1>My Portfolio</h1>

<img
src="images/profile.jpg"
alt="Profile photo"
width="300"
height="300">

<h2>My Projects</h2>

<img
src="images/project.png"
alt="Screenshot of my web development project">

</body>
</html>


๐Ÿง  Remember

<img>
โ†“
Displays an image

src
โ†“
Where the image comes from

alt
โ†“
Alternative description

width / height
โ†“
Image dimensions


Key Takeaway

The basic image structure is:

<img src="image.jpg" alt="Description of image">


The two most important attributes to remember are:

src โ†’ image location
alt โ†’ meaningful alternative text

Double Tap โค๏ธ For Part-18
  • โค 3
More from @webdevcoursefree
  1. Oct 13, 2026๐—ง๐—ข๐—ฃ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜๐—ฆ ๐—ง๐—ข ๐—•๐—ข๐—ข๐—ฆ๐—ง ๐—ฌ๐—ข๐—จ๐—ฅ ๐—ฆ๐—ž๐—œ๐—Ÿ๐—Ÿ๐—ฆ ๐—œ๐—ก ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! Explorโ€ฆ
  2. Oct 12, 2026For example: Go to Profile โ†’ <a> Submit Form โ†’ <button> Open Article โ†’ <a> Delete Accountโ€ฆ
  3. Oct 12, 2026๐ŸŒ Web Development Roadmap โ€” Part 16 HTML Links โ€” Tag Links are one of the most importantโ€ฆ
  4. Oct 12, 2026๐Ÿš€ ๐—ช๐—ต๐—ถ๐—ฐ๐—ต ๐—ง๐—ฒ๐—ฐ๐—ต ๐—ฆ๐—ธ๐—ถ๐—น๐—น ๐—ช๐—ถ๐—น๐—น ๐—ฌ๐—ผ๐˜‚ ๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ? Want to builโ€ฆ
  5. Oct 9, 2026Post #4079
  6. Oct 9, 2026Post #4078
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’