HTML and CSS Reference
In-Depth Information
Pick a style and stick with it
Just because you can use any of the aforementioned syntaxes doesn't mean you should mix them all up,
however. That would prove a maintenance nightmare, particularly in a large team.
Our advice is to pick a style that works for you and stick with 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.
Why such appallingly lax syntax? The answer is simple: browsers
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.
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, 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 find that it validates fine,
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