HTML Images

Text is great, but let’s be real — pictures make a webpage pop. Whether it’s a cute cat, a logo, or a meme, HTML’s <img> tag is how you bring images into the mix. It’s one of those tags that feels like magic the first time you see it work, and it’s crazy easy to use. Let’s jump in!

Here’s the basic setup:

<img src="cat.jpg" alt="A fluffy cat">

That src (source) bit tells the browser where your image lives — like “cat.jpg” if it’s in the same folder as your HTML file. The alt part? That’s a little backup text — if the image doesn’t load, or for folks using screen readers, it says “A fluffy cat” instead. Load that, and boom, your cat’s on the page!

I’ve tinkered with this a bunch. You can grab images from the web too:

<img src="https://example.com/dog.png" alt="A happy dog">

Just make sure you’ve got permission to use it — nobody likes a copyright snag. If it’s your own file, keep the path right — like src="images/puppy.jpg" if it’s in a subfolder called “images". I messed that up once, and all I got was a broken icon. Oops!

Want to tweak it? Add some attributes:

  1. width="200": Shrinks or stretches it to 200 pixels wide.
  2. height="150": Sets the height (play with both for size).

So:

<img src="sunset.jpg" alt="A pretty sunset" width="300" height="200">

That’ll show your sunset at a custom size — handy for fitting your layout.

Here’s a real combo I’ve tried:

<p>Check out my trip: <img src="beach.jpg" alt="Sandy beach" width="250"></p>

It’s chill next to the text, like a little postcard. One thing I learned: always use alt — it’s a small step that makes your page friendlier to everyone. Next time you’re coding, grab a pic you love and slap it in with <img>. It’s like decorating your digital room!

How-To Guides for HTML

No How-To Guide is available right now.

Keep Learning & Level Up!

Enhance your HTML skills with our in-depth tutorials and interactive quizzes.

Explore HTML Quiz