HTML and CSS Reference
In-Depth Information
Why such appallingly lax syntax? The answer is simple: brows-
ers never cared about XHTML syntax if it was sent as text/
html—only the XHTML validator did. Therefore, favouring one
form over the other in HTML5 would be entirely arbitrary, and
cause pages that didn't follow that format to be invalid, although
they would work perfectly in any browser. So HTML5 is agnostic
about which you use.
Pick a style and stick with it
Just because you can use any of the aforementioned formats doesn't mean you should mix them all up,
however. That would prove a maintenance nightmare, particularly in a large team.
Our advice is pick the style that works for you and stick to it. It doesn't matter which you choose; Remy
prefers XHTML syntax while Bruce prefers lowercase, attribute minimisation (so controls rather than
controls=”controls” ) and only quoting attributes when it's necessary, as in adding two classes to an
element, so <div class=important> but <div class=”important logged-in” . You'll see both styles
in this topic, as we each work as we feel most comfortable and you need to be able to read both.
As a brave new HTML5 author, you're free to choose—but having chosen, keep to it.
While we're on the subject of appallingly lax syntax rules (from
an XHTML perspective), let's cheat and, after adding the docu-
ment title, we'll go straight to the content:
<!doctype html>
<meta charset=utf-8>
<title>Interesting blog</title>
<p>Today I drank coffee for breakfast. 14 hours later,
¬ I went to bed.</p>
If we validate this exhilarating blog, we fi nd that it validates fi ne,
yet it has no <html> tag, no <head> , and no <body> ( Figure 1.1 ).
FIGURE 1.1 Shockingly, with
no head, body, or html tag, the
document validates.
Search WWH ::

Custom Search