Dismiss Notice
Welcome to Our Community
Wanting to join the rest of our members? Feel free to sign up today.

Adding interest to your pages with images

Discussion in 'Programming' started by gilbertsavier, Aug 4, 2009.

  1. gilbertsavier

    gilbertsavier New Member Webmaster

    Images can be used to make your Web pages distinctive and greatly help to get your message across. The simple way to add an image is using the <img> tag. Let's assume you have an image file called "peter.jpg" in the same folder/directory as your HTML file. It is 200 pixels wide by 150 pixels high.

    <img src="peter.jpg" width="200" height="150">

    The src attribute names the image file. The width and height aren't strictly necessary but help to speed the display of your Web page. Something is still missing! People who can't see the image need a description they can read in its absence. You can add a short description as follows:

    <img src="peter.jpg" width="200" height="150"
    alt="My friend Peter">

    The alt attribute is used to give the short description, in this case "My friend Peter". For complex images, you may need to also give a longer description. Assuming this has been written in the file "peter.html", you can add one as follows using the longdesc attribute:

    <img src="peter.jpg" width="200" height="150"
    alt="My friend Peter" longdesc="peter.html">

    You can create images in a number of ways, for instance with a digital camera, by scanning an image in, or creating one with a painting or drawing program. Most browsers understand GIF and JPEG image formats, newer browsers also understand the PNG image format. To avoid long delays while the image is downloaded over the network, you should avoid using large image files.

    Generally speaking, JPEG is best for photographs and other smoothly varying images, while GIF and PNG are good for graphics art involving flat areas of color, lines and text. All three formats support options for progressive rendering where a crude version of the image is sent first and progressively refined.
  2. Discountshop

    Discountshop New Member Webmaster


Featured Resources (View All)

Share This Page