Adding Images and Other Page Elements

Contents:

Summary of Object Placement Tags
Image Basics
The <img> Tag and Its Attributes
Horizontal Rules
Embedded Media Files
Java Applets

This chapter focuses on the HTML tags available for placing elements such as rules, images, or multimedia objects on a web page.

Summary of Object Placement Tags

In this section, browser support for each tag is noted to the right of the tag name. Browsers that do not support the tag are grayed out. Tag usage is indicated below the tag name. Start and end tags are required unless otherwise noted. "Deprecated" means that the tag or attribute is currently supported but is due to be phased out of the HTML specification and is discouraged from use (usually in favor of similar style sheet controls). The attributes listed for each tag reflect those in common use. A more thorough listing of attributes for each tag, according to the HTML 4.01 specification, appears in Appendix A, "HTML Elements"

<applet> NN 2, 3, 4, 6 MSIE 3, 4, 5, 5.5, 6 HTML 4.01 Opera5

<applet>...</applet>

Deprecated. This tag (first introduced in Netscape Navigator 2.0) is used to place a Java applet on the web page. <applet> and all its attributes have been deprecated in favor of the <object> element, but it is still widely used. Some applets require the use of the <applet> tag. Furthermore, Navigator 4 and earlier and Internet Explorer 4 do not support Java applets via object tags.

Attributes

<embed> NN 2, 3, 4, 6 MSIE 3, 4, 5, 5.5, 6 WebTV Opera5

<embed>...</embed>

Embeds an object into the web page. Embedded objects are most often multimedia files that require special plug-ins to display (for example, Flash movies, Quicktime Movies, etc.). In addition to the standard attributes listed below, certain media types and their respective plug-ins may have additional proprietary attributes for controlling the playback of the file. The closing tag is not always required, but is recommended.

Attributes

Internet Explorer only

Netscape Navigator only

<hr> NN 2, 3, 4, 6 MSIE 2, 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<hr> (no end tag)

Adds a horizontal rule to the page.

Attributes

<img> NN 2, 3, 4, 6 MSIE 2, 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<img> (no end tag)

Places a graphic on the page.

Attributes

Type Resulting alignment
absbottom Navigator 3.0 + and Internet Explorer 4.0 + only. Aligns the bottom of the image with the bottom of the current line.
absmiddle Navigator 3.0 + and Internet Explorer 4.0 + only. Aligns the middle of the image with the middle of the current line.
baseline Navigator 3.0 + and Internet Explorer 4.0 + only. Aligns the bottom of the image with the baseline of the current line.
bottom Aligns the bottom of the image with the text baseline. This is the default vertical alignment.
center According to the W3C specification, this centers the image horizontally on the page; however, in practice, browsers treat it the same as align=middle.
left Aligns the image on the left margin and allows subsequent text to wrap around it.
middle Aligns the text baseline with the middle of the image.
right Aligns the image on the right margin and allows subsequent text to wrap around it.
texttop Navigator only. Aligns the top of the image with the ascenders of the text line. An ascender is the part of a lowercase letter (like "d") that rises above the main body of the letter.
top Aligns the top of the image with the top of the tallest object on that line.

Internet Explorer's dynsrc attribute

Using a dynsrc attribute, Internet Explorer Versions 2.0 and later also use the <img> tag to place a video on the page. The following attributes are related to the dynsrc function and work only with Internet Explorer:

<marquee> MSIE 2, 3, 4, 5, 5.5, 6 WebTV

<marquee>...</marquee>

Creates a scrolling-text marquee area.

Attributes

<noembed> NN 2, 3, 4, 6 WebTV Opera

<noembed>...</noembed>

The text or object specified by <noembed> appears when an embedded object cannot be displayed (e.g., when the appropriate plug-in is not available). This tag is placed within the <embed> container tags.

<object> NN 3, 4, 6 MSIE 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<object>...</object>

A generic element used for placing an object (such as an image, applet, media file, etc.) on a web page. It is similar to the <embed> tag but is the W3C's approved method for adding elements to a page. Browser support for the <object> tag is not up to standards. Support in Navigator 4 is buggy, and in IE 4 (and even 5), the tag is generally useful only for ActiveX controls.

Attributes

<param> NN 2, 3, 4, 6 MSIE 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<param> (no end tag)

Supplies a parameter within the <applet> or <object> tag.

Attributes

<spacer> NN 3, 4, 6 WebTV

<spacer> (no end tag)

Holds a specified amount of blank space within the flow of a page. This is a proprietary tag introduced by Netscape; it met with controversy and is now rarely used in common practice. It can be used to maintain space within table cells for correct display in Navigator.

Attributes