HyperText Markup Language/Tag List/img

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Use[edit | edit source]

This tag is used to declare an image in the webpage. There are two formats you are to use on the web. They are: .gif (Graphics Interchange Format) and .jpg or .jpeg (Joint Photographic Expert Group).

Example[edit | edit source]

<img src="Beach.gif" alt="Beach Picture" height="300" width="200" title="Picture of the Beach"
align="right"/>

Required attributes[edit | edit source]

src[edit | edit source]

This must be used by the user. It declares the path of the image, in other words the source of the image.

alt[edit | edit source]

This used to be optional, now with XHTML coming into the spotlight, it is now compulsory to add this to the attributes list. All this does is add text to were the image is supposed to be when it cannot be found by the browser.

Optional attributes[edit | edit source]

align[edit | edit source]

Tells the browser were the image is supposed to be. The user has a choice of three values with this. They are: left, right and center.

height[edit | edit source]

This tells the browser how tall the image will be on the webpage. This must not be used to control the image size.

title[edit | edit source]

This declares text that is shown when the mouse is moved over the image.

width[edit | edit source]

Tells the browser the width of the image. Must not be used to control the image size.

Standard attributes[edit | edit source]

More info[edit | edit source]

http://yourhtmlsource.com/images/fileformats.html Images and Websites on yourhtmlsource.