O'Reilly logo

JavaScript® Bible, Seventh Edition by Paul Novitski, Danny Goodman, Tia Gustaff Rayl, Michael Morrison

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 40. HTML Directive Objects

IN THIS CHAPTER

  • Accessing non-displayed element objects

  • Linking operating system–specific style sheet definitions

  • HTML, head, link, title, meta, base, and script elements

Thanks to the modern browser's desire to expose all HTML elements to the document object model, we can now access a variety of objects that represent HTML elements that are normally invisible to the human viewer of a page. These elements are called directive elements because they predominantly contain instructions for the browser—instructions that direct the browser to locate associated content on the page, link in external specifications, treat content as executable script statements, and more.

As you browse through the objects of this chapter, you may wonder why they have so many properties that normally indicate that the elements occupy space on the rendered page. After all, how can a meta element have dimension or position on the page when it has no renderable content? The reason is that modern browsers internally employ some form of object-oriented behavior that lets all HTML elements—rendered or not—inherit the same set of properties, methods, and event handlers that any generic element has (see Chapter 26, "Generic HTML Element Objects"). The logical flaw is that unrendered elements can have properties and methods that don't genuinely apply to them. In such cases, their property values may be zero, an empty string, or an empty array. Yet the properties and methods exist in the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required