πΌοΈ Adding Images with <img> - Making Web Pages Visual
π August 15, 2025
βοΈ By Evans
Hey there, friends! π
After learning how to add links with the <a> tag, I wanted to make my pages look a bit more alive. Words are cool, but visuals? They make your page pop! π₯
That's when I learned about the <img> tag β the HTML tag used to add images to a web page.
Let's jump right in! πΌοΈ
π§± The Basic Image Tag
Heres the simplest way to add an image in HTML:
<img src="myphoto.jpg" alt="A picture of me learning HTML">
Let's break that down:
- <img> is the tag β and it doesn't need a closing tag!
- src (source) tells the browser where to find the image.
- alt (alternative text) describes the image β super important for accessibility and when the image fails to load.
π‘ Example:
If your image doesn't load, the text from alt appears instead. It also helps screen readers describe images to visually-impaired users.
ποΈ Linking to Images in Folders
If your image is inside a folder, you just include the folder name in the path:
<img src="images/profile.jpg" alt="Evans' profile photo">
That tells the browser to look for the image inside the images/ folder
π Using Online Images
You can also add images directly from the internet β just use the full URL:
<img src="https://example.com/pic.jpg" alt="Cool online picture">
β οΈ Be careful though β if that image is deleted or moved, it won't show up on your page anymore.
π Setting Image Size
You can control the width and height of images with attributes or, better yet, CSS:
<img src="photo.jpg" alt="Example" width="300" height="200">
But using CSS gives you more flexibility later on:
<img src="photo.jpg" alt="Example" style="width: 300px; height: auto;">
Using height: auto; keeps the image from stretching weirdly. π
π My Mistakes at First
- β Forgot to put the image in the right folder
- β Misspelled the image name (e.g. Photo.JPG instead of photo.jpg)
- β Didn't add alt, so when the image didnβt load, it just looked broken
πββοΈ Why alt is Important
esides helping with accessibility (for users using screen readers), the alt text also shows when the image can't load.
For example:
<img src="wrongname.jpg" alt="My profile picture">
If the image is missing, users will at least see βMy profile pictureβ instead of nothing.
πΌ My Practice Page
<h1>Welcome to Evans Blog</h1>
<p>Here's a photo from when I started learning HTML:</p>
<img src="images/learning.jpg" alt="Me coding at night" width="400">
π― What I Learned
The <img> tag taught me that HTML isn't just about text β it's about visual storytelling. Adding images made my pages feel more real and exciting to look at. It's that βwowβ moment when your blank page finally starts to look like a real website. π
π What's Next?
Next up, I'll be learning about Lists in HTML - Ordered and Unordered Lists.
We'll look at how to organize information neatly using <ul>, <ol>, and <li> tags.
Thanks again for reading, catch you in the next post!
β Evans πΈπ»