HTML and CSS Reference
In-Depth Information
When an element is placed inside of another element, also known as
nested
, it is a good idea
to indent that element to keep the document structure well organized and legible. In the pre-
vious code, both the
<head>
and
<body>
elements were nested—and indented—inside
the
<html>
element. The pattern of indenting for elements continues as new elements are
added inside the
<head>
and
<body>
elements.
Self-Closing Elements
In the previous example, the
<meta>
element had only one tag and didn't in-
clude a closing tag. Fear not, this was intentional. Not all elements consist of
opening and closing tags. Some elements simply receive their content or behavior
from attributes within a single tag. The
<meta>
element is one of these elements.
The content of the previous
<meta>
element is assigned with the use of the
charset
attribute and value. Other common self-closing elements include
•
<br>
•
<embed>
•
<hr>
•
<img>
•
<input>
•
<link>
•
<meta>
•
<param>
•
<source>
•
<wbr>
The structure outlined here, making use of the
<!DOCTYPE html>
document type and
<html>
,
<head>
, and
<body>
elements, is quite common. We'll want to keep this doc-
ument structure handy, as we'll be using it often as we create new HTML documents.
Search WWH ::
Custom Search