HTML The Definitive Guide (105 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

BOOK: HTML The Definitive Guide
10.37Mb size Format: txt, pdf, ePub

Here are a couple of valid image buttons: The browser displays the designated image within the form's content flow. The second button's image will be aligned with the top of the adjacent text, as specified by the align attribute. Some browsers (Netscape, for instance) also add a border, as it does when an image is part of an anchor ( tag), to signal that the image is a form button.

When the user clicks the image, the browser sends the horizontal offset, in pixels, of the mouse from the left edge of the image and the vertical offset from the top edge of the image to the server. These values are assigned the name of the image as specified with the name attribute, followed by .x and .y, respectively. Thus, if someone clicked the image specified earlier in the example, the browser would send parameters named map.x and map.y to the server.

Image buttons behave much like mouse-sensitive image maps (usemaps), and, like the programs or client-side tags that process image maps, your form-processor may use the x,y mouse-pointer parameters to choose a special course of action. You should use an image button when you need additional form information to process the user's request. If an image map of links is all you need, use a mouse-sensitive image map. Mouse-sensitive images also have the added benefit of providing server-side support for automatic detection of shape selection within the image, letting you deal with the image as a selectable collection of shapes. Buttons with images require you to write code that determines where the user clicked on the image and how this position can be translated to an appropriate action by the server.

Oddly, the HTML 4.0 standard allows the use of the usemap attribute with an image button, but does not explain how such a use might conflict with normal server processing of the x,y coordinates of the mouse position. We recommend not mixing the two, using mouse-sensitive images outside of forms and image buttons within forms.

10.5.4.4 Push buttons

Using the tag (or the ; never omitted

Contains:

button_content

Used in:

form_content

10.5.6.1 The tags becomes the content of the button, including any acceptable body content, such as text or multimedia. For instance, you could include an image and related text within a button, creating attractive labelled icons in your buttons. The only verboten element is an image map, since its mouse-and keyboard-sensitive actions interfere with the form button.

10.5.6.2 The type attribute

Use the type attribute for the

Notice that you can exploit the rich set of tag attributes, including align and alt, for this

Other books

Boo Hiss by Rene Gutteridge
Rabbit Ears by Maggie De Vries
A Killing Gift by Leslie Glass
Portrait Of A Lover by Julianne Maclean
Crashed by Dawn Robertson
Task Force by Brian Falkner
Carnal Gift by Pamela Clare