Chapter 15. Generic HTML Element Objects

IN THIS CHAPTER

  • Working with HTML element objects

  • Common properties and methods

  • Event handlers of all element objects

The object model specifications implemented in Internet Explorer 4 or later and W3C/Mozilla-based browsers feature a large set of scriptable objects that represent what we often call generic HTML elements. Generic elements can be divided into two groups. One group, such as the b and strike elements, defines font styles to be applied to enclosed sequences of text. The need for these elements (and the objects that represent them) is all but gone due to more page designers using style sheets. The second group of elements assigns context to content within their start and end tags. Examples of contextual elements include h1, blockquote, and the ubiquitous p element. Although browsers sometimes have consistent visual ways of rendering contextual elements by default (for example, the large bold font of an <h1> tag), the specific rendering is not the intended purpose of the tags. No formal standard dictates that text within an em element must be italicized: The style simply has become the custom since the very early days of browsers.

All of these generic elements share a large number of scriptable properties, methods, and event handlers. The sharing extends not only among generic elements, but also among virtually every renderable element—even if it has additional, element-specific properties, methods, and/or event handlers that I cover ...

Get JavaScript® Bible, Sixth Edition 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.