HTML and CSS Reference
In-Depth Information
Obviously, it will be apparent to the web developer that something is wrong if the
page does not render, but it will be far less apparent if the page renders fine, even if
there is an error the browser is handling. In such situations, the page is being handled,
but it is considered nonconforming with the HTML5 specification. This is why it is of
utmost importance that web developers are familiar with what has changed in HTML
and which elements and attributes they should not use (see the “Obsolete Features” sec-
tion later in this chapter). If in doubt, however, there are conformance-checking services
such as or that
will check supplied HTML code against the HTML5 specification.
Simplified doctype
HTML often begins with a doctype declaration. In the past this has looked something
like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transition-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
A doctype declaration provides an indication as to what Document Type Definition
(DTD) you're going to be writing your markup against. A DTD is basically a page de-
tailing the rules and grammar of the markup. So, the difference in the two lines of the
code listed earlier is that they are specifying a DTD for different versions of (X)HTML,
one HTML 4.01 and the other XHTML 1.0. Wait a minute! This heralds from a world-
view of HTML that sees it as broken into different versions. Since we are talking about
HTML5, which is backward-compatible with previous versions of the specification, all
that needs to be done is say the page is displaying HTML. Therefore, the doctype has
been simplified to the following:
<!DOCTYPE html>
How's that for simplification of the doctype? It really couldn't be any simpler. Well,
actually it could; it could be absent, and your HTML page will still load if it is omitted,
but don't erase this line from your web pages just yet!
Doctypes in HTML serve two important purposes. First, they inform user agents and
validators what DTD the document is written against. This action is passive—that is,
your browser isn't going and downloading the DTD every time a page loads to check
that your markup is valid; it's only when you manually validate a page that it kicks in.
Search WWH ::

Custom Search