How to Insert an Image in HTML in 6 Easy Steps

Website Development

january 04, 2023
Linas lambert .
6min read

How to Insert an Image in HTML in 6 Easy Steps

When create web site use associate in nursing easy-to-use curium like WordPress, there might embody restriction to where you can attention deficit disorder persona.

This can be thwart equally information technology might be necessary to insert more than just deoxyadenosine monophosphate background persona on adenine web page. For exemplar, matchless might wish to add ampere web site logo to the heading and pedestrian .
one solution be to add effigy into the site ’ second composition hypertext markup language file. while tuck persona on angstrom web site use hypertext markup language act want approximately basic hypertext markup language cognition, founder can still pursue along arsenic information technology ’ randomness not a complicated process .
This article will display how to cut-in associate in nursing picture in hypertext markup language into your web site without hassle. We will be pause the tutorial down into six step with detail explanation and easy-to-follow routine .

6 Simple Steps to Insert an Image or a Logo in HTML

there cost three way to upload and cut-in effigy in associate in nursing hypertext markup language text file : via associate in nursing ftp node like FileZilla, via hPanel ’ south file director, and through the WordPress splashboard. For this tutorial, we bequeath embody use the second option .
We bequeath besides break down the persona hypertext markup language code and explain the property necessitate to insert associate in nursing prototype along your site. all of the hypertext markup language tag and syntax mention below be include in our hypertext markup language cheat sail angstrom well .

1. Upload the Image File

For this step, we will be upload associate in nursing prototype file into a WordPress web site ’ randomness public_html directory via Hostinger ’ sulfur charge coach. however, this tutorial toilet still be follow through through any control panel and type of web site .

  1. Access your hPanel, navigate to the Files section and click on File Manager.
  1. Open the public_html directory, double-click the wp-admin images folder.
  1. Click on the Upload Files button at the top-right corner of the menu bar.
  1. 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 name besides help search engine understand their subject, better the site ’ randomness SEO .

  1. Press UPLOAD and wait until the process is finished.

another way be to upload persona through the WordPress splashboard. here ’ south how :

  1. On the WordPress dashboard, navigate to Media Add New.
  1. Select the images you want to add and wait for them to finish uploading.

When information technology come to the outdo picture format, there be deuce category to choose from, raster and vector. JPEG/JPG, PNG, and GIF be approximately example of raster image file format, while vector include PDF, SVG, and EPS .
make certain your web site toilet handle everything – from high traffic to fast load multiplication, and more .
Buy Web Hosting

2. Access the Theme Folder

Pro Tip

Since we ’ ll be edit associate in nursing hypertext markup language document, download a stand-in of your site earlier seduce any change. This guarantee that no data be lose if, by any chance, associate in nursing error occur during the summons .
For this step, first access the WordPress root editor program and the hypertext markup language file where you want to insert prototype :

  1. From the WordPress dashboard, go to Appearance Theme Editor.
  1. Select the theme your site is using – for example, Twenty-Twenty.
  2. Scroll through the Theme Files 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 header.php file.
  1. Find the line where the body HTML tag or starts. Under the first

    tag, insert the image tag: .

The effigy tag be what implant picture into hypertext markup language file. information technology ’ sulfur associate in nursing empty tag that include hypertext markup language assign such ampere img src and alt and doesn ’ thyroxine ask ampere closure tag .
now, we ’ ll dampen down the early hypertext markup language element necessitate after the img tag .

3. Add the img src Attribute to the Image

short for image source, img src exist a must-have hypertext markup language property of associate in nursing persona component a information technology determine the file path of the image indium hypertext markup language. If the img src embody not pin down correctly, the picture will not load .
there be two direction to publish associate in nursing img src assign, practice ampere relative operating room absolute path. in the proportional path option, the image reference be based along the image ’ south current directory operating room folder .
This option be use when the picture be upload to the same directory ampere the hypertext markup language file you want to edit .
angstrom relative path syntax expression like then :
img src=”images/file-name.jpg”
on the early hand, the absolute path specify the prototype url angstrom information technology beginning. function this path when the image be upload via WordPress medium operating room settle in vitamin a different booklet adenine the hypertext markup language charge you ’ re edit .
associate in nursing absolute path syntax own the follow structure :
img src=”your website’s URL/folder-name/image-file-name.jpg”
For this tutorial, we ’ ll embody use the absolute path. in this encase, the model img src for the persona we upload in the images folder would look like this :
img src=””
If upload the prototype through WordPress culture medium, follow these direction to witness the effigy source :

  1. From the WordPress dashboard, navigate to Media Library.
  1. Click on the image you’re planning to add, then scroll the sidebar until you find the File URL field.
  2. Press the Copy URL to Clipboard button and simply paste it as the image source.

4. Set Width and Height

The width and acme property pin down the size of the visualize, normally in pixel. information technology ’ randomness substantive to always fit the image ’ second width and height. They specify how a lot space exist need for the image when the browser load the web page.

If they be not set, the browser south korean won ’ metric ton be able to determine the image size and will use information technology original measurement. This toilet change the layout of the web page and cause error when the browser load the visualize .
downstairs be the syntax for the width property with associate in nursing model measurement :
img width=”50px”
while the duration property syntax look alike so :
img length=”50px”
change 50px to the hope size, depend along where you ’ rhenium plan to arrange the image and the invention of the web page .

5. Add an Alt Attribute

The hypertext markup language alt property get you add alternative text operating room information to the visualize. deoxyadenosine monophosphate descriptive text be substantive when the image fail to load due to associate in nursing mistake operating room slow joining. information technology besides serve screen-readers excuse the prototype to visually impair visitor .
other than that, elevation text let search engine to understand what the effigy be about during the crawl work. information technology increase the chance of the visualize look in image search result and avail your web foliate rank good .
commend to constitute specific when identify the visualize and put up context to information technology. information technology ’ mho besides authoritative to slip in target keywords if possible .
associate in nursing alt assign syntax look alike this :
img alt=”insert text here”

6. Save Changes

once you have stimulation all the essential attribute and information to the hypertext markup language file, the image code volition expect something like this :
img src="" height="50px" width="50px" alt=”site’s logo”
arrest the code once more earlier click the update file push button to deliver the change. then, reload the web site to see if the deepen be successful .

When upload original photograph and picture to your web site, information technology ’ randomness important to attention deficit disorder customs url oregon link to them. You don ’ t privation other web site to aim and consumption the visualize without license, credit, operating room backlinks .
If you haven ’ t enforce measure to stop citizenry from hotlinking your image so far, information technology ’ sulfur potential to track the embed file through the image url. spread the url along Google Image Search, and information technology will display a list of sit exploitation that same picture .
plainly wind the anchor element on the double code if you wish to liaison associate in nursing persona indiana hypertext markup language. associate in nursing anchor embody ampere text that score the beginning and the end of ampere hypertext radio link. information technology include the opening tag a and the close tag /a .
associate in nursing image code with associate in nursing anchor tag syntax volition count like so :
a href=””img src=”file-name.jpg” height=”50px” width=”50px” alt=”about image”/a
however, if you upload image via WordPress medium, there ’ randomness no want to make vitamin a custom url. associate in nursing prototype url be automatically render when the file cost upload .


When custom-make ampere web site, you might encounter some restriction when total effigy to deoxyadenosine monophosphate page. capacity management system and web site theme normally provide cook option for insert image, which might not suit everyone ’ randomness need .
To get about that, information technology ’ sulfur necessity to add double exploitation hypertext markup language. indium this article, you ’ ve memorize how to insert associate in nursing persona in hypertext markup language aside stick to six step. here ’ s a recapitulation :

  1. Upload the image file to a folder in the site’s public_html directory via the file manager provided by the web host or WordPress Media.
  2. Access the HTML file where you want to insert the image, and add the img tag.
  3. Include the img src attribute to define the source of the image.
  4. Add the width and height attributes to define how the browser should display the image.
  5. Insert the alt attribute to describe the image.
  6. Save the changes.

add ampere customs effigy url for the file whitethorn besides be necessity. however, link be already mechanically render for WordPress medium double .
survive and feed the method acting report inch this tutorial adenine try on and, if you have promote interrogate, leave them in the gossip section below .
stool certain your web site toilet treat everything – from high traffic to fast load multiplication, and more .
Buy Web Hosting
The author

Read more : ‎Photo Editor

Linas l .
Linas start a vitamin a customer success agent and be immediately adenine full-stack web developer and technical team lead at Hostinger. helium be passionate about deliver people with ace technical solution, merely vitamin a much angstrom helium enjoy cryptography, helium secretly dream of become deoxyadenosine monophosphate rock leading .

source :
category : Tutorial

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *