Computing Magazine

Images

Posted on the 29 January 2014 by Savio Menezes

Hello everybody. Today we’ll see how to display images in html documents. Images can be displayed using img tag.
<img src=”url”>
In src attribute you have to specify location of image usually web address but if image is in same folder as HTML file then you can directly mention name of image (along with extension). Other attributes of img are:
alt = usually a message that is displayed when web browser cannot display an image because of some error.
width= display image width in pixels.
height= display image height in pixels.
border= used to display border around image. Border is displayed in numbers. Greater the number thicker is the border. If you don’t want border then put border equal to zero. Border’s color is same as text color but if you are using image as a link than its color is same as link color (blue for unvisited link, red for active link and purple for visited link). 
Exercise
<!DOCTYPE html>
<html>
 <head>
  <title>
   Image demo
  </title>
 </head>
 <body>
  <h1>Image demo</h1>
  <img src="http://ubuntuone.com/0dDiMhFpybYKvMIICH1Gf9" alt="image" width="300" height="300" border="0">
 </body>
</html>
Output
To view html file click here.


Back to Featured Articles on Logo Paperblog

Magazines