ad

Monday, December 22, 2025

how to use the HTML img tag

How To Use The HTML <img> Tag 

web designing theory

Syntax 

 Syntax of HTML <img im> tag


<img src=" . . . " alt=" . . . ">


  • HTML image tag is <img> element denoted 
  • HTML <img> tag  use purpose embed image in your web page.
  • HTML  Image tag   write  <img src ="..."> 
  • HTML  Image tag   URL/path.  to the image
  • HTML  Image tag  self -closing tag. 
  • HTML  Image tag is not closing tag,(only opening tag).
  • HTML browser to display image form file use .png, .jpg, .gif, ... etc

 How To Use The HTML <img> Tag 
 Example  

<!DOCTYPE html>
<html>
  <head> HTML Image tag</head>
  <body>
    <h2> How To Use The HTML img Tag  </h2>
    <img src="https://img.freepik.com/free-photo/long-shot-bird-lake-with
    -blurred-background_23-2148245168.jpg?semt=ais_hybrid&w=740&q=80"
     width="200" height="200">
  </body>
</html>

How To Use The HTML <img> Tag 

Explain Program

Step  1] 

<!DOCTYPE html>

This declare the document type.

browser that the document is written in html

Step 2 ]

<html>.... . </html>

html is the root element of the html page.

 Every thing inside it is part of the webpage.

Step 3]

<head>
     
  <title> HTML Image tag </title>

    </head>

  <head>  section 

  head section contains metadata about page. not visible on the page itself.

 <title> tag  title section set the title of the page shows the browser tab.

Step 4]

<body>

< body> tag  contains all the content visible to webpage.

<body> tag contains  all the visible content of the page.

inside <body> show the browser screen.

Step 5]


<h1> How To Use The HTML img Tag </h1>
 
   

<h1> Tag heading  tag use for main title on webpage .

Step 6]

  <img src="https://img.freepik.com/free-photo/long-shot-bird-lake-with
    -blurred-background_23-2148245168.jpg?semt=ais_hybrid&w=740&q=80"
     width="200" height="200">

  <img>              :-  Use to display image on webpage.

 <src=" . . .">    : -  Picture URL  Source of the image .

 width="... "      :-   image width to 200 pixel.

 height ="..."     :-   image height  to 200 pixel.

Step 7]

closing the Tag

</body>

  </html>

How To Use The HTML <img> Tag 

Output

How To Use The HTML <img> Tag


Related Post :-

how to set image height

html link tag explain

how to use pre tag