Page 50 - DCAP408_WEB_PROGRAMMING
P. 50

Web Programming




                    Notes          2.3 Adding Images

                                   Images can be used to make your web  pages distinctive, and can greatly help  to get  your
                                   message across. .In HTML, images are defined with the <img> tag.
                                   The <img> tag is empty, which means that it contains attributes only and it has no closing tag.

                                   To display an image on a page, you need to use the src attribute. Src stands for “source”. The
                                   value of the src attribute is the URL of the image you want to display on your page.
                                   The syntax of defining an image:
                                          <img  src=”url”  />
                                          <img  src=”background.jpg”  width=”200"  height=”150">
                                   The URL points to the location where the image is stored.
                                   The browser puts the image where the image tag occurs in the document. If you put an image tag
                                   between two paragraphs, the browser shows the first paragraph, then the image, and then the
                                   second paragraph.
                                          <html>
                                          <body  background=”C:\Documents  and  Settings\All  Users\Documents\My
                                   Pictures\Sample             Pictures\Blue  hills.jpg”>
                                          <h1>Look:  A  background  image!</h1>
                                          <p><h2>Both  gif  and  jpg  files  can  be  used  as  HTML  backgrounds.</
                                   h2></p>
                                          <p><h3>If  the  image  is  smaller  than  the  page,  the  image  will  repeat
                                   itself.</h3></p>
                                          </body>
                                          </html>
                                   The output is shown in Figure 2.2.

                                                                     Figure  2.2
























                                   2.3.1 The Alt Attribute

                                   The alt attribute is used to define an “alternate text” for an image. The value of the alt attribute
                                   is an author-defined text.
                                   <img  src=”background.jpg”  alt=”bckgrnd”  />


          44                                LOVELY PROFESSIONAL UNIVERSITY
   45   46   47   48   49   50   51   52   53   54   55