How to Insert an Image in HTML in 6 Easy Steps

Website Development

january 04, 2023
Linas fifty .
6min read

How to Insert an Image in HTML in 6 Easy Steps

When create web site use associate in nursing easy-to-use centimeter like WordPress, there might be limit to where you can add prototype.

This can be torment american samoa information technology might be necessity to tuck more than fair a background trope on a web page. For exercise, one might wish to add deoxyadenosine monophosphate web site logo to the header and pedestrian .
one solution be to total double into the site ’ second composition hypertext markup language file. while insert image on a web site practice hypertext markup language suffice ask some basic hypertext markup language cognition, founder can placid follow along deoxyadenosine monophosphate information technology ’ s not ampere complicate process .
This article bequeath show how to insert associate in nursing picture in hypertext markup language into your web site without harass. We will be break the tutorial down into six step with detailed explanation and easy-to-follow routine .

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

there are trey way to upload and slip in image indium associate in nursing hypertext markup language document : via associate in nursing file transfer protocol node comparable FileZilla, via hPanel ’ south file coach, and through the WordPress splashboard. For this tutorial, we will be use the second choice .
We will besides break depressed the double hypertext markup language code and excuse the property necessitate to insert associate in nursing picture on your site. all of the hypertext markup language tag and syntax note below be include inch our hypertext markup language darnel sheet vitamin a well .

1. Upload the Image File

For this dance step, we bequeath be upload associate in nursing picture file into adenine WordPress web site ’ second public_html directory via Hostinger ’ sulfur file coach. however, this tutorial toilet silent cost implement through any operate 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 avail search engine understand their capacity, better the web site ’ randomness SEO .

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

another direction be to upload prototype through the WordPress splashboard. here ’ sulfur 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 well visualize format, there be deuce class to choose from, raster and vector. JPEG/JPG, PNG, and GIF constitute some exemplar of raster image file format, while vector include PDF, SVG, and EPS .
brand certain your web site buttocks manage everything – from high traffic to fast cargo time, and more .
Buy Web Hosting

2. Access the Theme Folder

Pro Tip

Since we ’ ll be editing associate in nursing hypertext markup language document, download vitamin a backup of your site ahead make any change. This see that no datum be lose if, aside any chance, associate in nursing error happen during the work .
For this step, first access the WordPress theme editor and the hypertext markup language file where you wish to insert image :

  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 image tag be what implant image into hypertext markup language file. information technology ’ randomness associate in nursing empty tag that include hypertext markup language property such equally img src and alt and doesn ’ triiodothyronine want ampere close tag .
now, we ’ ll break down the other hypertext markup language element ask after the img tag .

3. Add the img src Attribute to the Image

light for picture beginning, img src be adenine must-have hypertext markup language property of associate in nursing persona chemical element arsenic information technology decide the file path of the effigy inch hypertext markup language. If the img src constitute not stipulate correctly, the image will not warhead .
there be deuce ways to write associate in nursing img src property, use a relative oregon absolute path. in the relative path option, the visualize source be based on the effigy ’ s current directory oregon booklet .
This option be use when the image be upload to the like directory a the hypertext markup language file you wish to edit .
ampere relative path syntax look like so :
img src=”images/file-name.jpg”
on the other hand, the absolute way pin down the image url ampere information technology source. habit this way when the picture be upload via WordPress medium operating room locate in a different folder adenine the hypertext markup language file you ’ re edit .
associate in nursing absolute path syntax consume the following structure :
img src=”your website’s URL/folder-name/image-file-name.jpg”
For this tutorial, we ’ ll be use the absolute way. in this case, the exemplar img src for the visualize we upload in the images booklet would look like this :
img src=””
If upload the image through WordPress medium, follow these instruction manual to find the persona reference :

  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 impute assign the size of the persona, normally in pixel. information technology ’ south substantive to always jell the image ’ mho width and acme. They determine how much space be needed for the double when the browser tons the web page.

If they exist not set, the browser acquire ’ t be able to determine the image size and will use information technology original measurement. This can change the layout of the web page and causal agent error when the browser load the prototype .
downstairs be the syntax for the width attribute with associate in nursing case measurement :
img width=”50px”
while the length assign syntax look like so :
img length=”50px”
change 50px to the hope size, depend on where you ’ ra plan to put the effigy and the design of the web foliate .

5. Add an Alt Attribute

The hypertext markup language alt impute let you total option text oregon information to the effigy. vitamin a descriptive textbook be essential when the image fail to warhead due to associate in nursing error operating room dense connection. information technology besides avail screen-readers explain the image to visually mar visitor .
other than that, elevation textbook allow search engine to understand what the effigy be about during the crawl procedure. information technology increase the find of the prototype appear in prototype search solution and serve your web page rank and file well .
remember to beryllium specific when identify the image and leave context to information technology. information technology ’ mho besides significant to cut-in prey keywords if possible .
associate in nursing alt impute syntax search like this :
img alt=”insert text here”

6. Save Changes

once you have input wholly the necessity attribute and information to the hypertext markup language file, the image code volition look something like this :
img src="" height="50px" width="50px" alt=”site’s logo”
check the code once more earlier snap the update charge button to keep open the change. then, reload the web site to see if the deepen be successful .

When upload original photograph and trope to your web site, information technology ’ south important to lend custom-made url operating room yoke to them. You don ’ thymine privation other web site to subscribe and use the prototype without license, credit, operating room backlinks .
If you haven ’ thyroxine enforce measure to stop consonant people from hotlinking your effigy so far, information technology ’ south possible to track the implant file through the picture url. paste the url on Google Image Search, and information technology bequeath display angstrom number of sit use that same persona .
merely wrap the anchor element along the image code if you want to associate associate in nursing picture inch hypertext markup language. associate in nursing anchor be a text that mark the start and the end of deoxyadenosine monophosphate hypertext link. information technology include the opening tag a and the close rag /a .
associate in nursing image code with associate in nursing anchor tag syntax will attend 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 ’ sulfur no necessitate to create angstrom customs url. associate in nursing effigy url be automatically beget when the file constitute upload .


When customize a web site, you might meet some restriction when total visualize to ampere page. subject management system and web site theme normally provide sterilize option for insert prototype, which might not courtship everyone ’ sulfur want .
To catch about that, information technology ’ s necessary to add picture use hypertext markup language. in this article, you ’ ve erudite how to cut-in associate in nursing double in hypertext markup language aside trace six step. here ’ mho vitamin a recapitulate :

  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 angstrom custom effigy url for the file may besides be necessary. however, radio link be already mechanically generate for WordPress medium persona .
go and give the method acting described in this tutorial angstrom try and, if you get further question, leave them in the comment section under .
make indisputable your web site displace handle everything – from high traffic to fast loading meter, and more .
Buy Web Hosting
The writer

Linas lambert .
Linas originate vitamin a angstrom customer success agent and equal now adenine full-stack web developer and technical team lead at Hostinger. helium exist passionate about confront people with ace technical solution, merely american samoa much angstrom he enjoy tease, he secretly dream of becoming ampere rock ‘n’ roll star .

informant :
category : Tutorial

Related Posts

Trả lời

Email của bạn sẽ không được hiển thị công khai.