HTML and CSS Reference
In-Depth Information
4 See http://blog.whatwg.org/content-model-overhaul for a description of the impetus behind this
change.
Note There are actually a further seven minor categories that group elements
within specific contextual scenarios, such as when they are part of a form. To view
the additional categories, browse the category reference in the HTML specification
at http://dev.w3.org/html5/spec-author-view/
index.html#element-content-categories or http://whatwg.org/
specs/web-apps/current-work/#element-content-categories .
Root element
To begin looking at the elements in HTML, it makes sense to look at the begin-
ning—well, almost the beginning. We talked about the doctype declaration in the pre-
vious chapter, which is the first element to appear in an HTML document. However,
following the doctype declaration is the html element, which serves as the element that
encloses all other HTML elements in the document, otherwise known as the root ele-
ment .
The root element is one of a handful of elements whose tags are optional (see Table
2-3 for a list of other elements that include optional tags). Although the tags may be
optional, the element is not omitted. Optional elements will be implied if they are left
out (the body element being an exception, which will be omitted if no page content is
provided). For example, the following is a perfectly valid HTML5 document:
<!DOCTYPE html><title>Tiny HTML5</title><p>This is a valid
HTML5 page!
In this case, the missing tags of the html , head , body , and p elements are added
when parsing the document. It could even be shorter without the inclusion of the doctype
declaration, but that would trigger quirks mode in the web browser (for a discussion of
quirks mode, refer to the doctype section in Chapter 1 ).
Note For an easy way to check the validity of your documents against the current
HTML5 specification, visit http://html5.validator.nu or ht-
tp://validator.w3.org , both of which provide web-based services that valid-
ate supplied website URLs, uploaded HTML files, or directly input HTML. For the val-
idator housed at the W3C, ensure you set the document type in the validator drop-down
menu to “HTML5 (experimental)” to be certain you are checking it against the most
current specification.
 
Search WWH ::




Custom Search