Adding Images: Free HTML & CSS Tutorial
Master HTML Images with Professional Web Development Techniques
Essential HTML Elements Covered
Break Tag
Self-closing tag for creating line breaks in content. No closing tag required, simply performs its function.
Image Tag
Single tag for inserting images with source attribute. Supports JPEG and PNG formats with dimension specifications.
ALT Attributes
Accessibility text descriptions for screen readers and SEO optimization. Critical for inclusive web design.
index.html is reserved for homepage files. When visitors go to a website URL, index.html displays as the first page automatically.
Refresh your browser to see the image rendered on the page.
IMPORTANT: Images aren't embedded directly into HTML files—the img tag creates a reference to an external file. This means when you deploy your website to a production server, both your HTML files and your images folder must be uploaded to maintain the links. This architecture keeps HTML files lightweight while allowing browsers to cache images separately for better performance.
Now add a second image to create a visual gallery effect. Insert the following code below your first image:
<body>
<h1>
Latest News from The Onion:<br>
Today's Top National Headlines
</h1>
<img src="images/newsthumb-bill-gates.jpg" height="145" width="190" ALT="Bill Gates, Radiohead Fan">
<img src="images/newsthumb-wall-street-bull.jpg" height="145" width="190" ALT="Charging Bull">
<h2>Bill Gates Finally Getting Into Radiohead's <em>Kid A</em></h2>Save the file.
Refresh your browser and observe how the images display horizontally rather than stacking vertically.
ALT Text Benefits and Considerations
For purely decorative images, use empty ALT attribute (ALT='') or CSS techniques so screen readers can ignore them appropriately.
Images are not embedded into HTML pages. The img tag creates placeholders for linked files that must be uploaded to web servers.
Complete your image gallery by adding a third thumbnail:
<img src="images/newsthumb-bill-gates.jpg" height="145" width="190" ALT="Bill Gates, Radiohead Fan">
<img src="images/newsthumb-wall-street-bull.jpg" height="145" width="190" ALT="Charging Bull">
<img src="images/newsthumb-patent.jpg" height="145" width="190" ALT="Microsoft Patent Illustration">
<h2>Bill Gates Finally Getting Into Radiohead's <em>Kid A</em></h2>Save your work and refresh the browser to see your completed three-image gallery in action.
Keep both your code editor and browser open—you'll build upon this foundation in the next exercise where we'll explore advanced image positioning and responsive design techniques.
Key Takeaways
