Services

How can we help you?

Web design

Fusce sagittis et nisi in feugiat

SEO Services

Fusce sagittis et nisi in feugiat

eCommerce

Fusce sagittis et nisi in feugiat

Social media marketing

Fusce sagittis et nisi in feugiat

Advertisement

Fusce sagittis et nisi in feugiat

How to Insert Images in HTML Made Simple

by | Nov 8, 2025 | Uncategorized

Bringing a webpage to life with images is surprisingly straightforward. It all starts with a single, powerful HTML tag: <img>. This is the fundamental building block for adding any visual content, turning a simple text document into something far more engaging.

Your First Step to a Visual Web Page

A person pointing to a line of a computer screen, illustrating how to insert an image.

Let's be real. A blank web page staring back at you feels a bit… empty. You’ve got the words down, but text alone can feel flat, missing that spark that grabs a visitor's attention. We’ve all been there, wondering how to bridge that gap between a wall of code and a vibrant, visual experience.

The great news is, this isn't some complex secret guarded by coding wizards. It all begins with one simple HTML tag.

The Only Two Things You Absolutely Need

Here's the essential tag and attribute to get your first image on the page.

The Only Two Things You Absolutely Need
HTML Element What It Does Why It's Essential
<img> Tells the browser, "Hey, an image goes here!" It’s the container for your visual content.
src The "source" attribute. It provides the path or URL to the image file. Without it, the browser has no idea which image file to display.

These two elements work together. The <img> tag creates the space, and the src attribute provides the map to find the picture.

In Australia, getting this right is crucial. Visuals make a huge first impression, with some studies showing users spend an average of 5.94 seconds looking at a website's main image. That's your tiny window to capture their interest. Seriously, just a few seconds.

This small piece of code is a huge win. Seeing that first picture pop up on your page is a fantastic feeling. It's a foundational skill, whether you're coding from scratch or working with customisable WordPress websites in Brisbane. It’s the moment your project starts to feel real.

Why Alt Text Is Your Secret Superpower

A magnifying glass hovering over the alt text attribute in a line of HTML code, highlighting its importance.

So, you've got your image on the page, and it looks great. But what happens if the link breaks, leaving behind that dreaded broken image icon? More importantly, how do visitors using screen readers experience that visual content?

This is exactly where the alt attribute comes into play. You can think of it as a concise, plain-text description of your image that lives in the HTML code. It's not just a nice-to-have extra… it's a fundamental part of responsible, modern web development.

Giving Your Images a Voice

For someone relying on a screen reader, an image without alt text is just a silent gap on the page. A well-written alt attribute gives a voice to your visuals, clearly describing what's there so every user gets the complete picture. It's all about making the web accessible for everyone.

Good alt text isn't just a place to stuff keywords. It’s about crafting a short, descriptive sentence that genuinely explains the image's content and purpose to someone who can't see it.

For instance, simply writing alt="dog" is a missed opportunity. It's technically alt text, but it's not helpful.

A far better approach would be alt="A golden retriever catching a red frisbee in a sunny park". Can you see the difference? The first is lazy; the second actually paints a picture with words.

Beyond the massive accessibility benefits, alt text also gives your search engine optimisation a serious boost. Search engines can't 'see' images the way we do, but they can read this text to understand an image's context. This helps them rank your content more accurately. To dive deeper into this, check out this guide on how to optimize images for SEO, which covers everything from file formats to compression. It's a true win-win.

Taking Control of Image Sizing

You’ve just dropped a beautiful image onto your page, feeling pretty proud of yourself. You refresh the browser and… whoa. It's gigantic. It's a monster, pushing all your carefully written text off-screen and completely wrecking your layout.

It’s a classic beginner moment, and honestly, a really frustrating one. Images without clear dimensions can make an otherwise great website feel amateurish and broken. The good news? It's an easy fix. Let's get them under control.

This is all about using the width and height attributes directly inside your <img> tag. These tell the browser exactly what you want the image to do, giving you immediate control over your page design.

Pixels vs Percentages: A Quick Guide

You have two main ways to approach this, and knowing when to use each is key.

  • Fixed Pixels (px): Think of pixels as tiny, unchangeable dots on a screen. When you set width="300", you're telling the browser to render that image at exactly 300 pixels wide, period. This is perfect for elements like logos or small icons where you need precise, consistent sizing across the board.

  • Flexible Percentages (%): Using a percentage, like width="50%", is a whole different ball game. This tells the image to take up 50% of the space available in its parent container. If that container is a column that spans half the page, your image will take up half of that column. This is your first real step towards building layouts that adapt to different screen sizes.

Let's look at a quick example.

A snowy mountain peak at sunrise

In this snippet, we’ve locked the image to be exactly 500 pixels wide and 300 pixels high. Simple and effective.

This HTML-first approach is fantastic for getting started because it’s so direct. You add the attributes right there in the tag, and the image resizes. Job done.

As you get more comfortable with web design, you'll discover that CSS (Cascading Style Sheets) offers far more powerful and flexible control. But for now, mastering width and height in HTML is a huge leap forward in making your site look intentional and professional.

Making Images Work on Any Screen

Think about how you browse the web. Sometimes you're on a massive desktop monitor, other times it’s a tablet, and often it’s your phone squeezed into one hand on the train. It’s a safe bet your website visitors are doing the exact same thing.

An image that looks fantastic on a big screen can quickly become a slow, clunky mess on a mobile device. That’s the real challenge of responsive design. While it might sound complicated, solving it is actually easier than you might think.

This process flow shows how we can take a single large image and use a bit of code to deliver a perfectly sized version to every user, no matter their device.

Infographic about how to insert images in html

This visualises the core idea of responsive images, moving from a dated one-size-fits-all approach to a much smarter, code-driven solution.

Meet Your New Best Friend: The Srcset Attribute

Okay, this is where we get a bit more advanced, but stick with me because this is an absolute game-changer. The srcset attribute is an incredibly powerful tool that lets you give the browser a whole menu of image options.

You’re essentially saying, “Here are a few different sizes of the same picture… you pick the one that makes the most sense for the situation.” The browser then intelligently selects the best fit based on the user's device and screen resolution. It’s brilliant, really.

This single attribute can make a massive difference to your site's performance. It ensures your mobile users aren’t forced to download enormous files meant for a huge desktop monitor, which can be a massive drain on their data and patience.

In fact, Australian web design standards now often recommend specific dimensions for different views to improve loading efficiency. For example:

  • Desktop Background: 2560×1400 pixels
  • Mobile Background: 360×640 pixels

Using srcset is a pro-level move that makes your website faster and more user-friendly for everyone. It’s one of those behind-the-scenes details that elevates a good website into a great one.

Yes, it’s a bit more work upfront to create those multiple image sizes, but the payoff in speed and user experience is enormous. This kind of thoughtful design is a core principle behind modern web tools, and you can discover the power of Framer for web design to see how these concepts are being integrated into today's leading platforms.

Speeding Things Up With Lazy Loading

Imagine you’ve just landed on a long blog post, one packed with a dozen beautiful, high-resolution images. Does your browser really need to download all twelve of them the second the page opens? Especially the ones way down at the bottom you haven’t even scrolled to yet?

Probably not. That’s a whole lot of data being used upfront, and more importantly, it makes your visitor wait for things they can’t even see.

This is where a clever technique called lazy loading comes in. It’s one of those wonderfully simple ideas that makes you wonder why we ever did things any other way.

How loading="lazy" Works Its Magic

The best part is how incredibly easy it is to put this into practice. All you have to do is add one small attribute to your <img> tag: loading="lazy".

That’s it. Seriously. This single instruction tells the browser, "Hey, don't bother downloading this image until the user actually gets close to it."

This tiny change can have a massive impact on your initial page load time, creating a much smoother experience for your visitors. It also gives you a nice little boost in the eyes of Google, which always prefers a speedy website.

Since mid-2020, browsers like Chrome have gotten even smarter, fine-tuning the distance at which these images begin to load to ensure the experience is completely seamless.

This isn't just another performance tweak; it's a fundamental shift in how we should approach loading assets. You’re prioritising what the user needs right now, not what they might need eventually.

Of course, lazy loading is just one piece of the puzzle. For a comprehensive approach, you should also focus on image optimization for web performance.

This is especially critical for eCommerce sites where slow load times can directly hurt sales. If you're building an online store, applying these performance principles is non-negotiable. It's something we focus on heavily in our own guide to WooCommerce website design.

Common Questions About HTML Images

As you start embedding images, you'll inevitably run into a few common questions. These are the little snags that everyone hits when they're learning, so let's clear them up right now.

Think of this as your quick-reference FAQ for getting images to work just the way you want them to.

What Image Formats Should I Use?

This is probably the most frequent question I get. The format you choose can seriously impact your site's speed and visual quality, so it’s worth getting right.

For most photographic images, JPG (or JPEG) is your go-to. It's brilliant at compressing complex images with millions of colours, keeping file sizes manageable. If you're working with logos, icons, or any graphic that needs a transparent background, PNG is the clear choice. It keeps sharp lines crisp and clean.

And for those simple, looping animations? The trusty old GIF still does the job, though newer, more efficient formats are starting to take over.

Where Should I Store My Images?

You’ve got two solid options here, and the best one really just depends on your project's needs.

  • Self-hosting: The most straightforward method is to create an images folder right inside your project directory. This gives you complete control. Your image path will be relative, something like src="images/your-photo.jpg".
  • External hosting: You can also point your src attribute to an image hosted on another server or a Content Delivery Network (CDN). This is great for offloading bandwidth from your own server. The path will be an absolute URL, like src="https://some-cdn.com/path/to/image.jpg".

A word of caution on external hosting: if the image you're linking to gets moved or deleted, it will break on your site. Always ensure you have the rights to use an image before hotlinking to it!

Can an Image Also Be a Link?

You bet. Making an image clickable is one of the most common things you'll do, and thankfully, it's dead simple. All you have to do is wrap your <img> tag with an anchor <a> tag.

Here’s exactly how that looks in your code:

<a href="https://your-destination-url.com">
<img src="my-image.jpg" alt="A great description of the image">
</a>

Now, anyone who clicks that image will be taken straight to the URL you've set in the href attribute. It's a fantastic way to make your site more interactive and guide users to other pages.


Feeling ready to build a website that not only looks fantastic but also performs flawlessly? At Wise Web, we specialise in creating beautiful, high-performing websites for businesses just like yours. Let's chat about bringing your vision to life. https://wiseweb.com.au