HTML and CSS Reference
In-Depth Information
DOCTYPE
without DTD). Unlike the former, SGML-based HTML versions, HTML5
requires neither an FPI nor a reference to a DTD. The document type can be defined by the
DOCTYPE
declaration
<!DOCTYPE html>
. Since the
text/html
serialization of HTML5 is not
SGML-based, HTML5 applies the document type for mode selection only.
•
HTML5 (
<!DOCTYPE HTML>
Core Structure Elements
HTML documents must contain one element that is the parent of all other elements, that is, the
html
element.
This element is called the
root element
. It has been standardized in the HTML 2.0 specification, along with the other
two fundamental structure elements,
head
and
body
.
The
html
root element
contains all other elements within the document; in other words, the
<html>
starting tag
and the
</html>
closing tag delimit the document.
The HTML Head
The head section of HTML documents is the container of processing information and metadata. The document head
should be provided between the
<head>
and
</head>
tags and precede the document body.
Common elements in the HTML head (with one example for each) include the following:
title
element (required)
<title>Document title</title>
•
meta
elements
15
(optional, one or more)
<meta name="keywords" content="web standardization, valid XHTML5, valid
XHTML+RDFa, tableless CSS layout, W3C validation, WCAG, semantic web,
accessibility">
•
link
elements (optional, one or more)
<link rel="stylesheet" type="text/css" media="all" href="alt2.css"
title="Alternate style 2">
•
script
elements (optional, one or more)
<script type="text/javascript" src="js/loading.js"></script>
•
The document body is the main content of a web document. It might contain both block and inline elements
including, but not limited to, plain and formatted text, lists, headers, paragraphs, divisions, images, objects, forms,
and tables. However, there are prohibitions that determine which elements can be included in other elements.
Element Nesting
To maintain a logical document structure, certain HTML elements cannot contain all types of data or elements.
For example, elements of a table such as table body and data cells should be within a table; the
ins
element cannot
contain block-level content when it is used as an inline element, and so on. Some elements cannot contain other
enclosed elements of the same kind (e.g.,
form
,
label
). The content delimited by some elements can be a certain type
of data only (e.g.,
script
,
style
).
15
See Chapter 7 for details.
Search WWH ::
Custom Search