HTML and CSS Reference
The Web is made of documents. Well, mostly. There's an awful lot of non-text content on the Web: millions
of hours of video and audio, billions of photos and drawings, thousands of embeddable games and
widgets that require plug-ins, and a vast array of APIs and services working behind the scenes to move
information around the Web when it isn't in document form. But most of the time what you see and interact
with—what you probably call a web page —is a rendered HTML document. It might exist as a single self-
contained file on a web server, or it might be assembled on the server from separate pieces of code before
it's sent to your web browser, and some or all of it might be generated by dynamic scripts right before your
eyes… but it's still a document. When we refer to an HTML document we mean the entire collection of text
and markup that a browser renders into a web page.
You can view the source HTML document underlying any web page you visit, usually by selecting an
option in a contextual menu that appears if you right-click on the page, or from a View menu. Different
browsers put the option in different places and give it different names—usually “View Source” or
something similar—but every desktop browser has such a command. Viewing and studying the source
code of live websites is one of the best ways to learn how they're put together. Just remember: a great
many web pages still aren't built according to web standards and best practices, so quite often viewing the
markup of a live website will serve as a better example of what not to do.
In this chapter you'll learn about the parts of an HTML document and how it forms the surrounding
framework for the content of your web pages. The basic framework of a document is composed of just a
few essential parts, with a few other optional parts that are less essential but no less useful. We'll cover
each element one by one, explaining what it does, how to use it, what attributes it offers, and where the
element fits into the document.