HTML and CSS Reference
In-Depth Information
So which syntax model does HTML5 follow? Well, to date, both. The specifications for HTML5, as
they stand today, call for web authors to be able to choose whether they prefer to work in an HTML
or XHTML flavored language environment. Given the two different paths, we've decided to forge
ahead — right down the middle. There is enough overlap between the two choices to find common
ground and write web pages that will be acceptable under either syntax. Although this will entail
a few more rules than following a straight HTML syntax, it's a good type of structure, one that will
cause you to write standardized code without constraining your creative freedom. Details of the syn-
tax are described throughout the topic as various tags and attributes are explored.
undersTandin
T
T andin
G basic PaGe sTrucTure
For the most part, you can think of an HTML page as a series of containers. After an opening state-
ment that defines the type of page to follow, there is one large element, the <html> tag, that contains
the two primary structural elements, <head> and <body> . Here's how the essential code for an
HTML5 web page looks:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
The following sections explore each of the HTML elements that form the foundation for a web page
in turn, starting with the <!DOCTYPE html> .
setting a document Type
As the Web grew in complexity, browsers found that they needed some help to do their job well and as
quickly as possible. When a browser is asked to display a particular page of code, it helps to immedi-
ately identify the type of code the page contains. The document type instruction — also known as the
doctype — expressly states the flavor of the code to follow. Once a browser understands the doctype,
it can render the page faster and more accurately.
In HTML5, the doctype is expressed in a single line at the top of the file:
<!DOCTYPE html>
The mix of uppercase and lowercase is acceptable to both the HTML and XHTML syntax modes of
HTML5. Positioning is critical for the doctype statement, however: <!DOCTYPE html> must be the
first line before the HTML content begins.
All modern browsers, including recent versions of Internet Explorer, Firefox,
Safari, Google Chrome, and Opera go into what is known as standards mode
when encountering the <!DOCTYPE html> statement. Under standards
mode, browsers render the page according to established web standard protocols.
Search WWH ::




Custom Search