Dec 22, 2025
Linas L. & Ariffud M.
5min Read
Learning how to insert an image in HTML is important when you need to place a logo or graphic in a specific spot, like a header or footer, where your theme or content editor doesn’t allow it.
Adding images directly with HTML gives you full control over your site’s visual presentation. This enhances user engagement by breaking up text and improves branding by letting you place elements like logos exactly where they belong.
Here are the seven main steps to get your image live on your website:
Before you can add an image with code, that image needs to exist on your web server. This step involves optimizing your image file and uploading it to a location where it gets a direct, web-accessible URL, which you’ll need for the src attribute later.
For WordPress users, the most common way to do this is through the Media Library:

Alternatively, you can use your hosting control panel’s file manager. This method is great for static sites or for placing images outside the standard WordPress uploads folder.
For example, Hostinger users can use our intuitive File Manager. This tool gives you direct control over your site’s file structure. Simply navigate to your public_html directory (or a subfolder like images), and use the Upload button to add your file.


Accessing your theme’s HTML file involves editing the core template files, like header.php or footer.php, which control your site’s layout. To make your image appear on every page (like a header logo), you must edit these files rather than a single post.
Before editing theme files, always create a backup of your website. A small mistake here could break your site, and a backup means you can restore it quickly.
We also strongly recommend making these changes in a child theme to prevent your customizations from being overwritten when you update your main theme.
Once you have a backup, follow these steps in the WordPress theme editor:

To add the img src attribute, you will add the <img> tag to your HTML file and use the src attribute to define the image’s URL. The <img> tag is what tells the browser to display an image. It’s an “empty” tag, meaning it doesn’t need a closing tag (like </img>).
The src attribute (short for “source”) is the most crucial part, as it tells the browser where to find the image. This is where you’ll paste the File URL you copied from your Media Library in step 1.
Find the right spot in your code (for example, inside the <header> section in header.php) and add the following code snippet. Be sure to replace the placeholder URL with your actual image URL:
<img src="https://your-domain.tld/wp-content/uploads/2025/11/your-image.png">

This full URL is called an absolute path, which is the most reliable method to use when editing theme files.
You define the image width and height by adding the width and height attributes directly to your <img> tag. These attributes are critical for web performance and user experience because they tell the browser exactly how much space to reserve for the image before it even loads.
This practice prevents Cumulative Layout Shift (CLS), an annoying issue where page content “jumps around” as images load.
Add the width and height attributes to your <img> tag, specifying the image’s original dimensions in pixels.
<img src="https://your-domain.tld/wp-content/uploads/2025/11/your-image.png" width="180" height="60">
Please note that you only need to add the numbers. Do not add px inside the HTML attributes. Even if you use CSS to make the image responsive, setting these HTML attributes is still a best practice to define the image’s original aspect ratio.
The alt attribute (or alt text) is a short text description of your image. It’s essential for two main reasons:
Your alt text should be concise and descriptive. If the image is simply your logo, the alt text should be your company name followed by “logo”.
<img src="https://your-domain.tld/wp-content/uploads/2025/11/your-image.png" width="180" height="60" alt="A cat image">
To check for errors and save changes, you must review your <img> tag for typos and then click the Update File button in the WordPress editor. A single misplaced character or unclosed quote in your <img> tag can cause the image to break or affect the page layout.
Review your line of code one more time. Your complete <img> tag should look something like this:
<img src="https://your-domain.tld/wp-content/uploads/2025/11/your-logo.png" width="180" height="60" alt="A cat image">

Once you’re confident it’s correct, click the Update File button at the bottom of the Theme File Editor. Open your website in a new tab or a private browsing window and reload the page to see your new image.

You can add a link to an image by wrapping your <img> tag with an anchor (<a>) tag. An image in your header or footer, especially a logo, should almost always be a clickable link.
Users instinctively click on the logo to return to the homepage. Making your image a link is a “must-do” step for good site navigation and user experience.
The <a> tag uses the href attribute to define its destination URL. Here’s how to link your new logo to your website’s homepage:
<a href="https://your-domain.tld/"> <img src="https://your-domain.tld/wp-content/uploads/2025/11/your-logo.png" width="180" height="60" alt="A cat image"> </a>

After adding this code, click Update File again. Now, when you visit your site, your logo will not only be visible but will also function as a link.
Manually inserting an image using HTML is perfect for theme elements like logos. But as your site grows, you’ll be uploading dozens or even hundreds of images for your posts and pages.
This is where managing your assets becomes critical. A messy WordPress Media Library makes it hard to find images, reuse content, and get the correct URLs.
To organize your WordPress Media Library, you can install a plugin like FileBird to create virtual folders, and then simply drag and drop your media files into them.
By organizing your media with folders, you create a much faster and more reliable workflow for all your future content.
All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.