HTML and CSS Reference
In-Depth Information
white space characters into a single blank space. Thus, browsers treat the following para-
graph elements in the same way:
<p>Welcome to the J-Prop Shop.</p>
Welcome to the J-Prop Shop.
to the J-Prop Shop.</p>
<p>Welcome to the J-Prop Shop.</p>
Because HTML handles white space in this way, you can make your code easier for
others to read by indenting lines and adding extra blank lines to separate one tag from
another in the fi le.
HTML5 and XHTML Syntax
The rules that govern how code should be entered are called syntax . The way that HTML
has been implemented by most browsers through the Web's history has allowed for
minor variations in syntax. One reason for the success of the Web is that HTML has made
it easy for non-programmers to write and edit code without being ensnarled by syntax
On the other hand, XHTML forces strict syntax on page authors. If an author's code
does not follow the rules, browsers do not render the page. One advantage of this
approach is that it forces authors to write clear and more concise code; indeed, one of
the driving forces behind the development of XHTML was the desire to clean up some of
the messy and inconsistent code found on the Web.
For example, XHTML requires that all tag names be placed in lowercase letters and
that all attribute values be enclosed within quotation marks. HTML allows either upper-
case or lowercase tag names and does not require attribute values to be quoted. In
addition, XHTML requires that every one-sided tag be entered with a closing slash: for
instance, the br element must be entered as <br /> for XHTML compatibility. Most
browsers, however, accept HTML code in which one-sided tags are entered without clos-
ing slashes; thus, the br element could be entered either as <br> or as <br /> .
HTML5 supports the informal standards accepted by most browsers and will continue
to allow for minor variations in syntax. However, it is still good practice to write all code
to be XHTML compliant whenever possible, since it will allow that code to be easily
transferred to XHTML environments if necessary.
Exploring the Structure of an HTML Document
The structure of an HTML document consists of different elements nested within each
other in a hierarchy of elements. The top element in that hierarchy is the html element ,
which contains all of the other elements within an HTML fi le. Directly below the html
element in the hierarchy are the head and body elements. The head element contains
general information about the document—for example, the document's title, or a list of
Search WWH ::

Custom Search