src
The file or URL the browser should load.
Learn HTML Images with practical HTML examples for navigation, images, alt text, media behavior, metadata, accessibility, SEO and live practice.
HTML links and media
The img element embeds an image into the document. It is a void element, so it does not have a closing tag.
A professional image is not only src. It also needs the right alt text, dimensions, loading behavior and file size strategy.
Images can make a page feel premium, but they can also make a page slow, inaccessible or unstable if the markup is weak.
The file or URL the browser should load.
A text alternative for meaningful images.
Reserve layout space and reduce page jumping.
Can lazy-load images that are not immediately needed.
Syntax and structure
Use src for the file, alt for meaning, and width/height for layout stability.
<img src="/assets/img/course-dashboard.webp" alt="Course dashboard showing HTML lesson progress" width="960" height="540" loading="lazy" >
<img src="image1.jpg"> <img src="big-photo.jpg" alt="photo"> <img src="hero-final-final-new2.png" width="3000">
Rules that matter
Clickable and visual HTML affects how people move, scan, trust and share a page. The details are small, but the user experience impact is large.
Describe what the image communicates in this context.
Width and height help the browser avoid layout shift.
A huge photo can damage the whole page experience.
Do not delay critical hero images without thinking.
If the image is only decorative, CSS background-image may be a better fit.
Readable file names make projects easier to maintain.
Production thinking
Images matter because they are often the most emotional part of a page. Strong image HTML keeps that visual impact fast, stable and accessible.
Images that communicate meaning need alt text. Decorative images can use empty alt="" or CSS backgrounds so they do not add noise.
Prepare images in modern formats, correct dimensions and sensible compression. Visual quality and performance should be balanced.
Image file names, alt text and surrounding content help search engines understand image context, but keyword stuffing alt text is weak and bad for users.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.