HTML and CSS Reference
In-Depth Information
of the markup examples in this topic. Indenting nested elements can make it easier to see where a
particular element begins and ends, and thus you're less likely to run into nesting problems or forget to
close an element with the correct end tag.
Web browsers ignore any extra line breaks and carriage returns, collapsing multiple spaces into a single
space. To illustrate, here's a bit of markup with a lot of extra space:
This is a rather extreme example—one you'd probably never perpetrate yourself—but it serves to
demonstrate how all of those spaces are collapsed when a browser renders the document. Although the
spaces and returns are intact in the markup, your visitors would just see:
Wide open spaces!
Sometimes you may want to preserve extra spaces, tabs, and line breaks in your content—when you're
formatting poetry or displaying computer code, for instance. The pre element can delineate passages of
preformatted text in just such cases, and you'll learn more about that element in Chapter 4.
Adding Comments
It's often useful to embed comments in your documents. They're notes that aren't displayed in a browser
but that you (or someone else) can read when viewing the source markup. Comments can include
background on why a document is structured a particular way, instruction on how to update a document, or
a recorded history of changes. Comments in HTML use a specialized tag-like structure:
<!-- Use an h2 for subheadings -->
<h2>Adding Comments</h2>
A comment starts with <!-- , a set of characters the browser recognizes as the opening of a comment, and
ends with --> . Web browsers won't render any content or elements that occur between those markers,
even if the comment spans multiple lines. Comments can also be useful to temporarily “hide” portions of
markup when you're testing your web pages.
<!-- Hiding this for testing
<h2>Adding Comments</h2>
End hiding -->
Although a browser doesn't visibly render comments, the comments are still delivered along with the rest
of the markup and can be seen in the page's source code if a visitor views it. Don't expect comments to
remain completely secret, and don't rely on them to permanently remove or suppress any important
content or markup.
Search WWH ::

Custom Search