So, you're ready to add some pictures to your webpage? It's one of those things that makes a site feel real, you know? The secret is a little bit of HTML code called the <img> tag. It's the key to embedding images, but you've got to give it the right instructions. Think of it like telling your browser two simple things: what to show and where to find it.
Your First Step to Adding Images in HTML
Alright, let's get into it. You've got your image file sitting there. You're staring at your HTML code. And you're wondering how on earth to connect the two. Don't worry, we have all been there. It sounds super technical, but the idea behind it is actually pretty simple.
The hero of our story is the <img> tag. One of the nice things about it is that it's a self-closing tag… which is just a fancy way of saying you don't need a separate </img> to close it off. Easy.
But on its own, <img> is just an empty instruction. It needs a couple of critical pieces of information, which we call attributes, to actually show an image on the screen.
The Two Most Important Attributes
First up is the src attribute. It's short for "source." This is the file path that points the browser directly to your image. Get this path even slightly wrong, and you'll see that dreaded broken image icon. It’s such a classic mistake, but we'll cover how to get it right in a moment.
The second non-negotiable is the alt attribute, which stands for "alternative text." This is where you write a short, clear description of what's in your image. This little bit of text is incredibly important for a couple of big reasons:
- Accessibility: It lets screen readers describe the image to users with visual impairments. It's about making the web work for everyone.
- SEO: It gives search engines like Google some much-needed context about what your image is, helping it show up in image searches.
I really can't stress this enough. Skipping the
alttext is a huge misstep. Seriously. It’s one of the easiest ways to improve your site for both people and search engines, yet so many people just… forget. It only takes a second to write a good description, so try to make it a habit from day one.
So, if you were adding a profile picture to your new portfolio, the code would look a little something like this: <img src="images/profile-photo.jpg" alt="A professional headshot of Jane Doe smiling">.
Once you've got the hang of just getting the image onto the page, a great next step is learning how to make a picture a clickable link. It really adds a layer of interactivity to your site.
For now, though, let's just focus on getting that picture to show up. We can worry about making it fancy later.
Solving the Mystery of Image Paths
You've seen it, right? That frustrating little broken image icon staring back at you from a webpage you're building. It's a rite of passage for anyone learning HTML. I can tell you from experience that 99% of the time, the culprit is a dodgy path in your src attribute.
Let’s get this sorted out once and for all. It's all about giving the browser crystal-clear directions to find your image file, and there are two main ways to do this.
Imagine you're giving a friend directions to your house. You could give them the full street address (that's an absolute path). Or you could just say, "it's two doors down from here" (that's a relative path). Both work… but only in the right situation. Getting paths right is a fundamental part of good web design because honestly, nothing makes a site look more unprofessional than a bunch of broken images.
Relative Paths for Local Files
A relative path is your bread and butter. You'll use it most of the time because it points to an image that lives inside your own project folder. The path is written in relation to where your HTML file is sitting.
Let’s say you have a standard project setup:
index.html(your main page)images/(a folder)logo.pnghero-banner.jpg
If you're working inside index.html and want to display that logo.png file, the path is simple: <img src="images/logo.png" alt="Company Logo">. You’re just telling the browser to look inside the images folder from where it currently is.
But what if you need to go up a level? Say your HTML file was tucked away inside another folder, like
pages/about.html. To get to the images, you’d first need to go up one level to get back to the project's main folder. You do this with two dots:../images/logo.png. That little../simply means "go up one directory." It's like taking one step back.
Absolute Paths for External Images
An absolute path is the full web address (or URL) of an image that's hosted somewhere else online. It's the complete, unambiguous address, starting with https://. You'd use this when you need to pull in an image from another website or a content delivery network (CDN).
For example: <img src="https://some-other-website.com/images/photo.jpg" alt="A photo from another site">.
Just be a bit careful when hotlinking images like this. First, you've got to make sure you have permission to use them. Second, if the owner of that other site ever moves or deletes that image… poof. It'll break on your page without any warning. It’s completely out of your control.
Making Images Look Great on Any Device
Getting your image to actually show up is a massive first win. Seriously, take a moment to celebrate that. But now comes the part that separates a good-looking site from a clunky one… making sure that image looks professional on every single screen.
You’ve seen it before, haven't you? A website where you have to scroll sideways on your phone just to see the whole picture. It’s so annoying. A huge image can slow your site to a crawl, and a tiny one just looks blurry and amateur.
Setting a Simple Width and Height
Your first instinct might be to set the size right there in the HTML, and you can absolutely do that. The <img> tag has width and height attributes you can use.
<img src="images/sunset.jpg" alt="A vibrant sunset over the ocean" width="600" height="400">
This tells the browser to make the image exactly 600 pixels wide and 400 pixels tall. It works, but it's really rigid. What looks great on your big desktop monitor might be way too big for a phone screen. This is where we need to get a little smarter.
The Magic of Responsive Images
The real goal here is to make your images responsive. This just means they automatically shrink or grow to fit whatever screen they're on. No sideways scrolling. No awkward zooming. It's essential for a polished look, especially since a huge chunk of your visitors will be on mobile.
The secret ingredient here isn't more HTML. It’s a tiny little snippet of CSS (Cascading Style Sheets), the language that handles all the styling for a website. It's a real game-changer.
To make an image responsive, you can add this one simple rule to your stylesheet:
img { max-width: 100%; height: auto;}
This code tells the browser something like: "Never let an image be wider than the container it's in. And as you adjust the width, adjust the height automatically to keep the proportions right." Just like that, your images will adapt beautifully. Getting this right is a cornerstone of modern WordPress website design because it ensures a great user experience from the get-go.
Of course, getting great responsive images often starts with learning how to resize images for web before you even upload them. For local audiences, there are even some best practices that have been worked out.
Common Image Sizes for Australian Websites
Here’s a quick reference guide for standard image dimensions that work well for both desktop and mobile users in Australia. This is a great starting point for keeping your site fast and looking sharp.
| Image Type | Recommended Desktop Size (pixels) | Recommended Mobile Size (pixels) | Aspect Ratio |
|---|---|---|---|
| Hero/Banner Image | 2560 x 1400 | 360 x 640 | 16:9 |
| Blog Post Image (Full-width) | 1200 x 630 | 1200 x 630 | 1.91:1 |
| Product Image (Square) | 1024 x 1024 | 1024 x 1024 | 1:1 |
| Gallery Thumbnail | 400 x 400 | 400 x 400 | 1:1 |
For example, the 2025 guidelines for Australian websites suggest a background image should be around 2560 x 1400 pixels for desktop but only 360 x 640 for mobile. Following these standards helps deliver a consistent, high-quality experience for everyone. It’s little details like this that make a difference.
Why Alt Text Is Your Secret SEO Weapon
I get it. After wrestling with paths and getting your image to finally show up, filling in that little alt attribute can feel like a chore. It’s so tempting to just skip it and move on.
But trust me on this one: don't. That little bit of text is far more powerful than it looks. It's your secret weapon for making your website more accessible and for getting found on Google.
First, let's talk about accessibility. Imagine someone is using a screen reader to browse your site. They can't see that brilliant photo you've picked out, so your alt text is what they 'hear' instead. It’s your chance to paint a picture with words, describing the image and making sure your content is inclusive for everyone. It’s such a small effort that makes a massive difference.
More Than Just Words to Google
Then there’s the SEO side of things. Google is incredibly smart, but it can’t actually see your images like a person can. It relies on the text surrounding an image to figure out what it's all about.
A well-written, descriptive alt text gives Google crucial context. It connects your image directly to the rest of your content, which can give you a genuine boost in search rankings. It's not just a box to tick off a list.
It's now standard practice for a reason. With the average user spending just 5.94 seconds looking at a website’s main image, that first impression has to be perfect for everyone… and that includes search engines. You can discover more insights about Australian web design statistics to see why these little details matter so much.
So, how do you write great alt text? It's simpler than you think.
-
Be descriptive but concise. What's actually happening in the image? "A golden retriever catching a red frisbee at the park" tells a much better story than just "dog."
-
Weave in your keywords naturally. If it makes sense, include your target keyword. For a page about dog training, something like "golden retriever learning a frisbee catch during dog training" works perfectly.
-
Don't stuff it with keywords. Never, ever force it. An alt text like "dog puppy retriever pet animal playing" is just spammy. It sounds robotic and doesn't help anyone.
Ultimately, writing good alt text is all about being helpful. First to your visitors, and second to the search engines that help them find you.
Advanced Tips for Faster, Smarter Images
Alright, so your images are showing up and they're looking sharp on the page. That's a fantastic start. But if you want your website to be truly fast and efficient, we can go a step further.
Once you've nailed the basics, a few extra tweaks can make a massive difference to your site's performance, especially for visitors on their phones. The single biggest win here is a technique called lazy loading.
It might sound complicated, but it's surprisingly easy. You just add loading="lazy" directly into your <img> tag. That's it. That's the whole thing.
So, How Does Lazy Loading Work?
That simple attribute is a signal to the browser. It says, "Don't bother downloading this image right now. Wait until the user actually scrolls down and gets close to it." It’s a total game-changer for page speed. Without it, a browser tries to download every single image the moment the page loads, which can really slow things down.
You'll see a huge improvement on pages with lots of images, like a product gallery. In fact, getting this right is a fundamental part of quality Shopify website design because faster pages mean happier customers and better sales.
This isn't just a clever trick anymore; it's a standard for modern web development. Even Google has refined how Chrome handles lazy loading to be more efficient. If you want to dive deeper, you can read the full details on how browser-level lazy loading works straight from the source.
Here are a couple of other quick wins you can do right away:
- Pick the right file format: Stick with JPGs for photographs and complex images. Use PNGs when you need a transparent background. For everything else, modern formats like WebP give you fantastic quality at a much smaller file size.
- Always compress your images: Before you upload anything, run your images through a compression tool. This shrinks the file size dramatically, often without you even noticing a difference in quality.
These aren't just obscure tips for developers. They're essential practices for building a website that feels professional and responsive for every single person who visits.
Common Questions About HTML Images
Alright, let's wrap this up by tackling some of the questions that always seem to pop up. These are the little sticking points that can turn a five-minute job into a frustrating hour of googling. Having these answers handy will save you a world of pain down the track.
One of the biggest questions I hear is, "Can I use any image format?" For the most part, yeah. Modern browsers are pretty amazing and can handle almost anything you throw at them, but it’s best to stick to the main players: JPG, PNG, GIF, and WebP.
My rule of thumb is this:
- JPGs are your go-to for photos.
- PNGs are perfect for anything needing a transparent background, like logos.
- WebP is the modern hero. Use it whenever you can for its fantastic compression that keeps quality high and file sizes low.
Can I Put Text Over an Image?
Absolutely. This is a super common need for things like hero banners with a big, bold headline. But here's the catch: you don't do it directly with the <img> tag itself.
This is a job for CSS. Think of HTML as the skeleton that places the image on the page, and CSS as the artist that paints the text on top. You’d typically place your <img> inside a container (like a <div>) and then use CSS positioning to place your text exactly where you want it. It's a two-step process, but it gives you total control over the final look.
A quick heads-up: when you do put text over an image, always make sure there's enough contrast. White text on a busy, light-coloured photo is a recipe for unreadable content. Sometimes adding a subtle dark overlay to the image in CSS can make the text pop beautifully.
What About Copyrights?
This one is really important. Can you just use any image you find online? The short, safe answer is no.
Always assume an image is copyrighted unless you know for sure it isn't. Your best bet is to use sites that offer royalty-free stock photos or make sure you have explicit permission from the creator. Grabbing a random image from Google Images is a risky game you really don’t want to play.
Feeling like all this coding is a bit much? If you want a stunning website without getting lost in the code, the team at Wise Web can build a beautiful, high-performing site for your business. Let us handle the technical details so you can focus on what you do best. Check out our web design services.

