{"id":618,"date":"2021-09-01T12:20:00","date_gmt":"2021-09-01T12:20:00","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/uncategorized\/websitehow-to-add-image-or-logo-to-your-website\/"},"modified":"2025-03-10T11:50:53","modified_gmt":"2025-03-10T11:50:53","slug":"website-how-to-add-image-or-logo-to-your-website","status":"publish","type":"post","link":"\/ph\/tutorials\/website\/how-to-add-image-or-logo-to-your-website","title":{"rendered":"How to insert an image in HTML in 6 easy steps"},"content":{"rendered":"<p>When creating websites with a popular CMS like WordPress, there may be restrictions on where you can add images.<\/p><p>This can be aggravating because it may be necessary to insert more than just a background image on a web page. For example, one might want to include a website logo in the header and footer.<\/p><p>One option is to include images in the site&rsquo;s theme HTML file. While inserting images on a website using HTML in WordPress does require some basic HTML knowledge, beginners can still follow along because the process is not difficult.<\/p><p>This article will show you how to easily insert an image in HTML into your website. We will divide the tutorial into six steps, each with detailed explanations and easy-to-follow procedures.<\/p><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/How-to-Speed-Up-Your-Website-EN.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook-Speed-Up-your-website-1024x283.png\" alt=\"\" class=\"wp-image-69260\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/eBook-Speed-Up-your-website-1536x425.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/eBook-Speed-Up-your-website-300x83.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/eBook-Speed-Up-your-website-150x41.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/eBook-Speed-Up-your-website-768x212.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/eBook-Speed-Up-your-website.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>\n\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-insert-an-image-or-a-logo-using-html\">How to insert an image or a logo using HTML<\/h2><p>There are three ways to upload and insert images in an HTML document: via an <a href=\"\/ph\/tutorials\/ftp\/filezilla-ftp-configuration\">FTP client like FileZilla<\/a>, via hPanel&rsquo;s file manager, and through the WordPress dashboard. For this tutorial, we will be using the second option.<\/p><p>We will also break down the image HTML code and explain the attributes needed to insert an image on your site. All the HTML tags and syntax mentioned below are included in our <a href=\"\/ph\/tutorials\/html-cheat-sheet\">HTML Cheat Sheet<\/a> as well.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-upload-the-image-file\">1. Upload the image file<\/h3><p>For this step, we will be uploading an image file into a WordPress website&rsquo;s <strong>public_html<\/strong> directory via <a href=\"\/ph\/tutorials\/how-to-use-hostinger-file-manager\/\">Hostinger&rsquo;s file manager<\/a>. However, this tutorial can still be implemented through any control panel and type of website.<\/p><ol class=\"wp-block-list\">\n<li>Access your <strong>hPanel<\/strong>, navigate to the <strong>Files <\/strong>section, and click on <strong>File Manager<\/strong>.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager.png\"><img decoding=\"async\" width=\"1024\" height=\"175\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-1024x175.png\" alt=\"hPanel's File Manager menu\" class=\"wp-image-79420\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-files-filemanager-1024x175.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-files-filemanager-300x51.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-files-filemanager-150x26.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-files-filemanager-768x131.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-files-filemanager.png 1141w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><ol start=\"2\" class=\"wp-block-list\">\n<li>Open the <strong>public_html <\/strong>directory and double-click the <strong>wp-admin <\/strong>&ndash;<strong> images<\/strong> folder.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-public_html-wpadmin-images.png\"><img decoding=\"async\" width=\"1024\" height=\"169\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-public_html-wpadmin-images-1024x169.png\" alt=\"Images folder is highlighted in wp-admin folder.\" class=\"wp-image-80618\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-files-filemanager-public_html-wpadmin-images.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-files-filemanager-public_html-wpadmin-images-300x49.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-files-filemanager-public_html-wpadmin-images-150x25.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-files-filemanager-public_html-wpadmin-images-768x127.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><ol start=\"3\" class=\"wp-block-list\">\n<li>Click on the <strong>Upload Files<\/strong> button at the top-right corner of the menu bar and select <strong>File<\/strong>.<\/li>\n<\/ol><figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/hPanel-files-filemanager-public_html-upload-filehighlighted.png\"><img decoding=\"async\" width=\"397\" height=\"321\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/hPanel-files-filemanager-public_html-upload-filehighlighted.png\" alt=\"The Upload pop-up window with the File option highlighted\" class=\"wp-image-78222\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/hPanel-files-filemanager-public_html-upload-filehighlighted.png 397w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/hPanel-files-filemanager-public_html-upload-filehighlighted-300x243.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/hPanel-files-filemanager-public_html-upload-filehighlighted-150x121.png 150w\" sizes=\"(max-width: 397px) 100vw, 397px\" \/><\/a><\/figure><ol start=\"4\" class=\"wp-block-list\">\n<li>Select the image files you want to upload. Ensure that the file names are easy to read and descriptive, as they will be the title attribute of the HTML images. Plus, remember to add dashes to separate the words. Clear image file names also help search engines understand their content, improving the <a href=\"\/ph\/tutorials\/what-is-seo\/\">site&rsquo;s SEO<\/a>.<\/li>\n<\/ol><ol start=\"5\" class=\"wp-block-list\">\n<li>Press <strong>UPLOAD <\/strong>and wait until the process is finished.<\/li>\n<\/ol><p>Another way is to <a href=\"\/ph\/tutorials\/how-to-add-images-wordpress\">add images through the WordPress dashboard<\/a>. Here&rsquo;s how:<\/p><ol class=\"wp-block-list\">\n<li>On the <strong>WordPress dashboard<\/strong>, navigate to<strong> Media <\/strong>&ndash;<strong> Add New<\/strong>.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/WordPress-media-add-new.png\"><img decoding=\"async\" width=\"1024\" height=\"390\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/WordPress-media-add-new-1024x390.png\" alt=\"Screenshot from the WordPress dashboard showing where to find Media and click on Add New.\" class=\"wp-image-35743\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-media-add-new-1024x390.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-media-add-new-300x114.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-media-add-new-150x57.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-media-add-new-768x293.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-media-add-new.png 1344w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><ol start=\"2\" class=\"wp-block-list\">\n<li>Select the images you want to add and wait for them to finish uploading.<\/li>\n<\/ol><p>When it comes to the <a href=\"\/ph\/tutorials\/best-image-formats\">best image formats<\/a>, there are two categories to choose from, <strong>raster<\/strong> and <strong>vector<\/strong>. <strong>JPEG\/JPG<\/strong>, <strong>PNG<\/strong>, and <strong>GIF<\/strong> are some examples of raster image file formats, while vectors include <strong>PDF<\/strong>, <strong>SVG<\/strong>, and <strong>EPS<\/strong>.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-full\"><a href=\"\/ph\/web-hosting\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\" alt=\"Hostinger web hosting banner\" class=\"wp-image-98604\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/11\/Web-hosting_in-text-banner.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/11\/Web-hosting_in-text-banner-300x88.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/11\/Web-hosting_in-text-banner-150x44.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/11\/Web-hosting_in-text-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-2-access-the-theme-folder\">2. Access the Theme Folder<\/h3><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>Since we&rsquo;ll be editing an HTML document, download a backup of your site before making any changes. This ensures that no data is lost if, by any chance, an error occurs during the process.<\/p>\n                <\/div>\n\n\n\n<\/p><p>For this step, first access the <a href=\"\/ph\/tutorials\/wordpress-theme-editor\/\">WordPress theme editor<\/a> and the HTML file where you want to insert images:<\/p><ol class=\"wp-block-list\">\n<li>From the <strong>WordPress dashboard<\/strong>, go to<strong> Appearance <\/strong>&ndash;<strong> Theme Editor<\/strong>.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/WordPress-theme-editor.png\"><img decoding=\"async\" width=\"1024\" height=\"454\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/WordPress-theme-editor-1024x454.png\" alt=\"Screenshot from the WordPress dashboard showing where to find the Theme Editor.\" class=\"wp-image-35744\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-theme-editor-1024x454.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-theme-editor-300x133.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-theme-editor-150x66.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-theme-editor-768x340.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-theme-editor.png 1347w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><ol start=\"2\" class=\"wp-block-list\">\n<li>Select the theme your site is using &ndash; for example, <strong>Twenty-Twenty<\/strong>.<\/li>\n\n\n\n<li>Scroll through the <strong>Theme Files<\/strong> section and click on the HTML file you want to add an image to. For example, if you want to add a logo to the header, click the <strong>header.php<\/strong> file.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/theme-header.png\"><img decoding=\"async\" width=\"1024\" height=\"481\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/theme-header-1024x481.png\" alt=\"The Theme Header (header.php) file.\" class=\"wp-image-35745\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/theme-header-1024x481.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/theme-header-300x141.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/theme-header-150x71.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/theme-header-768x361.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/theme-header.png 1285w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><ol start=\"4\" class=\"wp-block-list\">\n<li>Find the line where the <strong>body HTML <\/strong>tag<strong> <\/strong>or <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">&lt;body&gt;<\/code> starts. Under the first <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">&lt;div&gt;<\/code> tag, insert the<strong> <\/strong>image tag: <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">&lt;img&gt;<\/code>.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/edit-themes-img-2.png\"><img decoding=\"async\" width=\"1024\" height=\"550\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/edit-themes-img-2-1024x550.png\" alt=\"Inserting the img tag in the HTML body.\" class=\"wp-image-35754\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/edit-themes-img-2-1024x550.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/edit-themes-img-2-300x161.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/edit-themes-img-2-150x81.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/edit-themes-img-2-768x412.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/edit-themes-img-2.png 1144w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>The <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">&lt;img&gt;<\/code><strong> <\/strong>tag is what embeds images into HTML files. It&rsquo;s an empty tag that includes HTML attributes such as <strong>src<\/strong> and <strong>alt<\/strong> and doesn&rsquo;t require a closing tag.<\/p><p>Now, we&rsquo;ll break down the other HTML elements required after the <strong>img<\/strong> tag.<\/p><h3 class=\"wp-block-heading\" id=\"h-3-add-the-img-src-attribute-to-the-image\">3. Add the img src attribute to the image<\/h3><p>Short for image source, <strong><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">src<\/code><\/strong> is a must-have HTML attribute of an image element as it determines the file path of the image in HTML. If the <strong><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">src<\/code><\/strong> is not specified correctly, the image will not load.<\/p><p>There are two ways to write an image source attribute, using a relative or absolute path. In the relative path option, the image source is based on the image&rsquo;s current directory or folder.<\/p><p>This option is used when the image is uploaded to the same directory as the HTML file you want to edit.<\/p><p>A relative path syntax looks like so:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;img src=&rdquo;images\/file-name.jpg&rdquo;\/&gt;<\/pre><p>On the other hand, the absolute path specifies the image URL as its source. Use this path when the images are uploaded via WordPress Media or located in a different folder as the HTML file you&rsquo;re editing.<\/p><p>An absolute path syntax has the following structure:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;img src=&rdquo;your website&rsquo;s URL\/folder-name\/image-file-name.jpg&rdquo;\/&gt;<\/pre><p>For this tutorial, we&rsquo;ll be using the absolute path. In this case, the example image source for the image we uploaded in the <strong>images <\/strong>folder would look like this:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;img src=&rdquo;https:\/\/yoursite.com\/wp-admin\/images\/website-logo.png&rdquo;\/&gt;<\/pre><p>If uploading the image through WordPress media, follow these instructions to find the image source:<\/p><ol class=\"wp-block-list\">\n<li>From the <strong>WordPress dashboard<\/strong>, navigate to <strong>Media <\/strong>&ndash;<strong> Library<\/strong>.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/WordPress-media-library.png\"><img decoding=\"async\" width=\"1024\" height=\"450\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/WordPress-media-library-1024x450.png\" alt=\"Screenshot from the WordPress media showing where to find the Library.\" class=\"wp-image-35748\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-media-library-1024x450.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-media-library-300x132.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-media-library-150x66.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-media-library-768x338.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/WordPress-media-library.png 1346w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><ol start=\"2\" class=\"wp-block-list\">\n<li>Click on the image you&rsquo;re planning to add, then scroll the sidebar until you find the File URL field.<\/li>\n\n\n\n<li>Press the <strong>Copy URL to Clipboard<\/strong> button and simply paste it as the image source.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/file-url.png\"><img decoding=\"async\" width=\"1024\" height=\"459\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/file-url-1024x459.png\" alt=\"Pasting the URL as the image source.\" class=\"wp-image-35749\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/file-url-1024x459.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/file-url-300x135.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/file-url-150x67.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/file-url-768x345.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/file-url.png 1286w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-4-set-width-and-height\">4. Set width and height<\/h3><p>The width and height attributes specify the size of the image, usually in pixels. It&rsquo;s essential to always set the image&rsquo;s width and height. They determine how much space is needed for the image when the browser loads the web page.<\/p><p>If they are not set, the browser won&rsquo;t be able to determine the image size and will use its original measurements. This can change the layout of the web page and cause errors when the browser loads the image.<\/p><p>Below is the syntax for the width attribute with an example measurement:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;img width=&rdquo;50px&rdquo;\/&gt;<\/pre><p>While the height attribute syntax looks like so:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;img height=&rdquo;50px&rdquo;\/&gt;<\/pre><p>Change <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">50px<\/code> to the desired size, depending on where you&rsquo;re planning to put the image and the design of the web page.<\/p><h3 class=\"wp-block-heading\" id=\"h-5-add-an-alt-attribute\">5. Add an alt attribute<\/h3><p>The HTML <strong>alt<\/strong> attribute lets you add alternative text or information to the image. A descriptive text is essential when the image fails to load due to an error or slow connection. It also helps screen-readers explain the image to visually impaired visitors.<\/p><p>Other than that, alt text allows search engines to understand what the image is about during the crawling process. It increases the chance of the images appearing in image search results and helps your web page rank better.<\/p><p>Remember to be specific when describing the image and provide context to it. It&rsquo;s also important to insert target keywords if possible.<\/p><p>An <strong>alt<\/strong> attribute syntax looks like this:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;img alt=&rdquo;insert text here&rdquo;\/&gt;<\/pre><h3 class=\"wp-block-heading\" id=\"h-6-save-changes\">6. Save changes<\/h3><p>Once you have input all the essential attributes and information into the HTML image file, the image tag will look something like this:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;img src=\"https:\/\/yoursite.com\/wp-admin\/images\/website-logo.png\" height=\"50px\" width=\"50px\" alt=&rdquo;site&rsquo;s logo&rdquo;\/&gt;<\/pre><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/image-code.png\"><img decoding=\"async\" width=\"1024\" height=\"550\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/image-code-1024x550.png\" alt=\"How the image code looks in the HTML body.\" class=\"wp-image-35750\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/image-code-1024x550.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/image-code-300x161.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/image-code-150x81.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/image-code-768x413.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/image-code.png 1143w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>Check the code once more before clicking the Update File button to save the changes. Then, reload the website to see if the changes are successful.<\/p><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/sample-post.png\"><img decoding=\"async\" width=\"1024\" height=\"376\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/sample-post-1024x376.png\" alt=\"The successfully changed website's front page.\" class=\"wp-image-35751\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/sample-post.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/sample-post-300x110.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/sample-post-150x55.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/09\/sample-post-768x282.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-bonus-step-add-a-link-to-the-image\">Bonus step: Add a link to the image<\/h3><p>When uploading original photos and images to your website, it&rsquo;s important to add custom URLs or links to them. You don&rsquo;t want other websites to take and use the images without permission, credit, or backlinks.<\/p><p>If you haven&rsquo;t implemented <a href=\"\/ph\/tutorials\/hotlinking\">measures to stop people from hotlinking your images<\/a> yet, it&rsquo;s possible to track the embedded files through the image URL. Paste the URL on <strong>Google Image Search<\/strong>, and it will display a list of sites using that same image.<\/p><p>Simply wrap the anchor element on the image element if you want to link an image in HTML. An anchor is a text that marks the start and the end of a hypertext link. It includes the opening tag &lt;<code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">a<\/code>&gt; and the closing tag &lt;<code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/a<\/code>&gt;.<\/p><p>An image element with an anchor tag syntax will look like so:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;a href=\"www.yourwebsite.com\/image-name.html\"&gt;&lt;img src=\"file-name.jpg\" height=\"50px\" width=\"50px\" alt=\"about image\"&gt;&lt;\/a&gt;<\/pre><p>However, if you upload images via WordPress Media, there&rsquo;s no need to create a custom URL. An image URL is automatically generated when the file is uploaded.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>Learn <a href=\"\/ph\/tutorials\/how-to-create-a-logo\">how to create a logo<\/a> with Hostinger AI Logo Maker.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>When customizing a website, you might encounter some limitations when adding images to a page. Content management systems and website themes usually provide fixed options for inserting images, which might not suit everyone&rsquo;s needs.<\/p><p>To get around that, it&rsquo;s necessary to add images using HTML. In this article, you&rsquo;ve learned how to insert an image in HTML by following six steps. Here&rsquo;s a recap:<\/p><ol class=\"wp-block-list\">\n<li>Upload the image file to a folder in the site&rsquo;s <strong>public_html<\/strong> directory via the file manager provided by the web host or WordPress Media.<\/li>\n\n\n\n<li>Access the HTML file where you want to insert the image, and add the <strong>img <\/strong>tag.<\/li>\n\n\n\n<li>Include the <strong>img src<\/strong> attribute to define the source of the image.<\/li>\n\n\n\n<li>Add the <strong>width<\/strong> and <strong>height<\/strong> attributes to define how the browser should display the image.<\/li>\n\n\n\n<li>Insert the <strong>alt<\/strong> attribute to describe the image.<\/li>\n\n\n\n<li>Save the changes.<\/li>\n<\/ol><p>Adding a custom image URL for the files may also be necessary. However, links are already automatically generated for WordPress media images.<\/p><p>Go and give the methods described in this tutorial a try and, if you have further questions, leave them in the comment section below.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-full\"><a href=\"\/ph\/web-hosting\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\" alt=\"Hostinger web hosting banner\" class=\"wp-image-98604\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/11\/Web-hosting_in-text-banner.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/11\/Web-hosting_in-text-banner-300x88.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/11\/Web-hosting_in-text-banner-150x44.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/11\/Web-hosting_in-text-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>When creating websites with a popular CMS like WordPress, there may be restrictions on where you can add images. This can be aggravating because it may be necessary to insert more than just a background image on a web page. For example, one might want to include a website logo in the header and footer. [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ph\/tutorials\/website\/how-to-add-image-or-logo-to-your-website\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Insert an Image in HTML Easily in 6 Steps","rank_math_description":"Images and logos can attract a new audience. Check out our article and learn how to add an image or logo to your site by using HTML.","rank_math_focus_keyword":"add image with html","footnotes":""},"categories":[],"tags":[],"class_list":["post-618","post","type-post","status-publish","format-standard","hentry"],"hreflangs":[],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/comments?post=618"}],"version-history":[{"count":32,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/618\/revisions"}],"predecessor-version":[{"id":124780,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/618\/revisions\/124780"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/media?parent=618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/categories?post=618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/tags?post=618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}