Position HTML Elements with Dynamic HTML

One exciting possibility with Dynamic HTML is the capability to reposition HTML elements on the Web page. To do this, change the left and top properties of the element's style object (which, in turn, is a property of the element). This change can be done either automatically or in response to user interaction.

Listing 25.6 shows an example of a Dynamic HTML document that enables the user to position an HTML element—in this case a group of pictures—on the Web page. In this example, a table containing three images is contained within a <span> element. An onclick event is attached to the <span>, which is used to toggle whether it can be moved and to initialize the coordinates for the move. An onmousemove ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.