ad

Monday, December 22, 2025

how to use the HTML img tag

How To Use The HTML <img> Tag 

web designing theory

This Blog You Will Learn 

What is the <imag> tag?
Syntax of HTML <img im> tag
 How to Write HTML TAG
How src Works
Important Rules for alt
Explain Program
Output

What is the <imag> tag?

✅HTML <img> tag is used to embed images in your web pages.
creates a placeholder than  picture will appear,
 HTML <img> tag is a self colsing tag.
<img> tag  doesn't separate closing tag.
HTML Image tag make webpage more  attractive and  engaging.
You creating a business site, personal blog,portfolio website,education 

 Syntax of HTML <img im> tag


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

 How to Write HTML TAG
  • 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 src Works

src attribute   source use HTML to tell browser.
  src attribute provides path or URL image file. 
 finds the image at that location.
 Relative path points to image inside your project folder.

How alt  Works
  1. alt attribute  (alternative text)
  2. alt use with <img> tag to describe image information.
  3. alt use with <img> tag help use and browsers understand what image is about  when
  4.  image cannot be display to browser this time refer to use and browser .
Important Rules for alt
  •  Always include alt
  •  Describe the image clearly
  •  keep is information meaningful
  •  Do not  write image of picture.
  • Leave empty (alt=" " ) for decorative images
 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