HTML and CSS Reference
In-Depth Information
Start tags can also have attributes: a
name optionally followed by a value.
An attribute is used to select between
different options of element function
or to provide extra information about
what the element describes.
Some elements need to have at least one attribute to be any use; for
instance, a <link> element has an attribute that contains the address of
the HTML page it links to. Some attributes are specific to certain ele-
ments, and others can be applied to any element. The two most com-
mon attributes you'll see are id , to assign a unique identifier to an
element, and class , to assign a space-separated list of classes (think of
them as categories or tags). You'll see these two attributes a lot in
appendix C when you learn about CSS .
Elements can contain text, but they can
also contain other elements. In this
example we would say, “The <p>
element contains the <em> element.”
Any element that contains other ele-
ments is said to be the parent of those
other elements; those are in turn its chil-
dren —the idea is that the elements form
a tree structure, like a family tree.
The <p> element has two children: the
text “A paragraph” and an <em>
element. The <em> element has one
child: the text it contains.
HTML documents
An HTML document is a tree of elements descending from an <html> ele-
ment and its two children: <head> for metadata (literally, “data about
data”) and other nonvisible elements, and <body> for the page content.
Search WWH ::

Custom Search