Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 118 - 2626_South Point_C-7
P. 118

    <IMG> Tag and its Attributes

                      The <img> tag is an HTML element used for embedding images in a document. It's a self-closing tag,
                      meaning it doesn't have a separate closing tag.

                      Despite  its  apparent  simplicity,  the  <img>  element  has  a  wide  range  of attributes  that  allow you
                      to  create  stunning  images  for your  webpages.  These  qualities  have been  categorised  for your
                      convenience. Let's us explore the attributes given below:

                      SRC(Source)

                      SRC specifies the source or URL of the image that has to be inserted in the web page.
                      For example,

                         <img src="C:\Mydocuments\rose.jpg">

                      Height

                      The height attribute specifies the height of the image on the web page. For example,

                      <img src="C:\Mydocuments\rose.jpg" height="20%">

                      Width

                      The width attribute specifies the width of the image on the web page. For example,

                      <img src="C:\Mydocuments\rose.jpg" width="32%">

                      Alt

                      It specifies the alternate text to be displayed in the web browser if the provided image is not found.
                      For example,

                      <img src=" C:\Mydocuments\rose.jpg" alt=" rose image">
                      Let us use the <IMG> tag to insert an image on the web page in the following way:

                      Applying Border to an Image

                      It specifies the thickness of the border surrounding the image. For example,
                      <img src="C:\Mydocuments\rose.jpg" style="border: 2px dotted red;">

                        <!DOCTYPE html>
                        <HTML>
                        <HEAD>

                            <TITLE>Image of a Rose</TITLE>
                        </HEAD>
                            <BODY>
                            <H1>Roses</H1>

                      116   Premium Edition-VII

| 113 114 115 116 117 118 119 120 121 122 123 |