HTML – IMAGES | Readstall

HTML – IMAGES

05-02-19 Gudditi Naganjaneyulu 0 comment

Images are very important to beautify as well as to depict many complex concepts in a simple way on your web page. This tutorial will take you through simple steps to use images in your web pages.

Insert Image

You can insert any image in your web page by using <img> tag. Following is the simple syntax to use this tag.

<img src = “Image URL” … attributes-list/>

The <img> tag is an empty tag, which means that, it can contain only list of attributes and it has no closing tag.

Example

To try following example, let’s keep our HTML file test.htm and image file test.png in the same directory −

  1. <!DOCTYPE html>
  2. <html>
  3.  <head>
  4.  <title>Using Image in Webpage</title>
  5.   </head>
  6.   <body>
  7.   <p>Simple Image Insert</p>
  8.   <img src =” C:\Users\gudditi\Desktop\r logo copy.png” alt = “Test Image” />
  9.  </body>
  10.  </html>

This will produce the following result :

                                                       

Set Image Width/Height

You can set the image width and height based on your requirement using width and height attributes. You can specify the width and height of the image in terms of either pixels or percentage of its actual size.

EXAMPLE :

  1. <!DOCTYPE html>
  2. <html>
  3.  <head>
  4.  <title>Set Image Width and Height</title>
  5.  </head>
  6.  <body>
  7.   <img src = ” C:\Users\gudditi\Desktop\r logo copy.png ” alt = “Test Image” width = “150” height = “100”/>
  8.   </body>
  9.   </html>

This will produce the following result –

Set Image Border

By default, the image will have a border around it, you can specify the border thickness in terms of pixels using border attributes. A thickness of 0 means, no border around the picture.<!DOCTYPE html>

  1. <html>
  2. <head>
  3. <title>Set Image Border</title>
  4. </head>
  5. <body>
  6. <p>Setting image Border</p>
  7. <img src = “/html/images/test.png” alt = “Test Image” border = “3”/>
  8. </body>
  9. </html>

This will produce the following result −

@@@



Leave a reply