HTML and CSS Reference
In-Depth Information
HTML Document Structure
HTML documents apply a platform- and language-independent interface known as the Document Object Model
( DOM ) that makes it possible to refer to and manipulate markup elements as objects [45]. This model provides
dynamic content access and updates as well as document styling for scripts [46]. The DOM can be considered a
mechanism that makes web pages behave like applications [47]. The DOM can be visualized as a tree structure for the
hierarchy of markup elements within a document (Listing 3-31, Figure 3-2 ).
Listing 3-31. A Well-Structured HTML Document
<!DOCTYPE html>
<title>A DOM example</title>
<link rel="stylesheet"
<p>Paragraph content</p>
rel: "stylesheet"
type: "text/css"
href: "main.css"
Figure 3-2. The DOM tree of Listing 3-31
Improperly closed elements and the missing closing tags destroy the DOM structure, which often has serious
consequences such as disrupted layout or incorrect styling. Thanks to the built-in error-handling feature of web
browsers, many markup errors are corrected on-the-fly, but the intended structure can be presumed only so the
correct web site layout and styling is not guaranteed. Developers should not rely on this error-handling feature!
An HTML document usually consists of a Document Type Declaration (DTD), a Formal Public Identifier (FPI),
and a link associating the document with the appropriate DTD at the very beginning of the file (except HTML5
documents that usually omit the DTD). All HTML documents must have an html root element 14 that contains the
document head and the document body [48].
14 Even if the element was marked optional in the HTML 4.01 specification.
Search WWH ::

Custom Search