Документация
HTML CSS PHP PERL другое
The img Element
 
Previous Page
Table of Contents
Next Page

The img Element

When working with images, the element you'll be using is img

<img />

Placed all by itself within the body of your document, this will do nothing at all. So along with the img element itself, you'll need to point to the location of the image. This is done using the src attribute, which stands for "source."

In the value of the source attribute, you'll add the location and the name of the actual web graphic file, along with its extension. Example 3-1 shows a complete document with the image source included.

Example 3-1. Adding the image into the document body
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>

<title>Chapter 3</title>

</head>

<body>

<img src="/images/010/photo.jpg" />

</body>
</html>

NOTE

small site, in one image location off the root directory.


This causes the image to appear in your browser window (see Figure 3-1).

Figure 3-1. The image appears within the browser window.


  • Assist browsers with better rendering

  • Provide helpful information to those who might not be able to view the image

  • Link the image

NOTE

You'll explore how to do these things using XHTML first, but in Chapter 8, "Working with Color and Images Using CSS," you'll learn more advanced methods to control an image's presentation using CSS.


    Previous Page
    Table of Contents
    Next Page


     Приглашаем посетить сайты 
    Мода Чехов Крылов Автомобили Брюсов Горький Грибоедов Хлебников Ходасевич CSS