HTML Image Tag

Updated:06/24/2021 by Computer Hope

HTML img tag is used to display image on the web page. HTML img tag is an empty tag that contains attributes only, closing tags are not used in HTML image element.

The image given by the src attribute is the embedded content, and the value of the alt attribute is the img element's fallback content.

Below is an example of  Image Tag  written in HTML.
   <!-- 
Example contain a Img tag   of html.
It is  just create a simple web page in web browser
Note : open note paid and Save this code on notepad with extension of .html 
then right click and select option of Open with in Window user ,run with any browser and display output .
   -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
           <head>
            <title>Example page</title>
            <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
           </head>
           <body>
            <h1>This is a heading</h1>

          <!--
           here you can able see attribute of Img Tag
          -->
                         
           <h2  >HTML Image Example  </h2  >  
          <img src="good_morning.webp" alt="Good Morning Friends"/  >
        

            <img src="images/smiley.webp" width="30" height="30" alt="Smiley"> 
            <a href="https://www.google.com/" title="Search Engine"> Google</a> 
            <a title="Hyper Text Markup Language"> HTML </a> 
            <input type="text" value="John Doe"> 
          
            <p>This is an <b>example</b> of a basic HTML page.</p>
           </body>
   </html>

Features of HTML Image Tag

  •   HTML Image Tag  is used to describe the source or path of the image to be displayed
  •  Src  mandatory attribute of the HTML image tag Since the height and the width of the image is not specified, hence the image will be displayed in its full size
  •   alt attribute  It is used to specify an alternate text for the image to be displayed. The value of the alt attribute is usually a text describing the image and is displayed if the image itself is not displayed on the browser for any reason, and is also good for SEO perspective.

Latest Html Article