HTML Tutorial 8

Prepared by: Anthony Larrain


Images

To display an image use the <img> tag.

Example 1

Suppose you have a JPEG image file called tree.jpg in the same directory as your HTML file. To display an image put the following into the HTML document.

<img src="tree.jpg" />

Browser Display

Example 1 ... Explained

Example 2

Specifying a path to the image file other than the current directory

<img src="images/tree.jpg" /> <img src="http://students.depaul.edu/~alarrain/hci201/lab/tree.jpg" />

Example 2 ... Explained


Image Attributes

Width and Height Attributes

Example 1

<img src="tree.jpg" width="200" height="133">
Design Tips

Example 2

Using HTML to change the dimensions of the image

<img src="tree.jpg" width="400" height="300">

Browser Display

The alt Attribute

Example 3

<img src="tree.jpg" alt="A picture of a tree" width="200" height="133" />

Browser Display

A picture of a tree

The title Attribute

Provides a tooltip for the user.

Example 4

<img src="tree.jpg" title="Photo taken from FreeFoto.com" alt="A picture of a tree" width="200" height="133" />

Browser Display

A picture of a tree

@Anthony Larrain 2005 - 2006

Send Questions or Comments to hci201@yahoo.com