|
|
Free HTML lesson - how to include images in web pages part 1Let's start this section with an image of the beautiful Aishwarya Rai.
Including images is very simple. You employ the <IMG> tag. The required attribute of this tag is SRC, which takes the value of the image file's URL. <IMG SRC="ash.jpg"> The SRC attribute determines the source of the image file and takes a URL as value. I have used a relative URL which shows that ash.jpg is located in the same directory as this file. Three kinds of images files .gif, .jpg and .png are used on the Internet. A general rule of thumb is to use .jpgs for photographs and .gifs for images containing large blocks of single colors. The <IMG> tag has many attributes
The size attributes, WIDTH and HEIGHT Your image will display correctly even if you skip using these attributes. However, you should ALWAYS include them as this helps the browser window to allocate space for your image. Let us examine the image below. Its width and height values in pixels are 150 and 100, respectively. ![]() <IMG SRC="hat.gif" width="150" height="100"> Now see what happens if we specify 200 as width and 50 as height. ![]() <IMG SRC="hat.gif" width="200" height="50"> The image is distorted! It means that the width and height attributes force the image to be displayed in that space regardless of what the actual dimensions are. BORDER attribute ![]() <IMG SRC="hat.gif" width="150" height="100" border="2"> ![]() <IMG SRC="hat.gif" width="150" height="100" border="8"> ALT attribute Visitors using text-based browsers or who have turned off images in their browsers will not be able to see the image. However, they would be able to read the image description through the ALT attribute. Also, the ALT attribute value will be read by speech browsers, employed by visually impaired visitors. So be a good developer and insert the ALT attribute always. Place your mouse pointer above the image to display text ![]() <IMG SRC="hat.gif" width="150" height="100" border="1" alt="A green colored hat">
Page contents: Free html lesson - how to include images in web pages - online html lesson for beginners - free online html lesson
Page URL: http://www.webdevelopersnotes.com/tutorials/html/ 19.php3
|
|