XHTML Syntax (Cont.)
The id Attribute Replaces the name Attribute
HTML 4.01 defines a name attribute for the elements a, applet, frame, iframe, img, and map.
| Wrong |
Correct |
<img src="picture.gif"
name="picture1" />
|
<img src="picture.gif"
id="picture1" />
|
To interoperate with older browsers, you should use both
name and
id, with identical attribute values.
To make your XHTML compatible with today’s browsers, you should add an extra space before the ‘/’ symbol.
<img src="picture.gif" id="picture1" name="picture1" />
|
The lang Attribute
The
lang attribute applies to almost every XHTML element.
It specifies the language of the content within an element.
If you use the
lang attribute in an element, you must add the
xml:lang attribute, like this:
<div lang="no" xml:lang="no">Heia Norge!</div>
|
Mandatory XHTML Elements
All XHTML documents must have a DOCTYPE declaration.
The
html,
head, and
body elements must be present, and the
title must be present inside the
head element.
The xmlns attribute in <html>, specifies the xml namespace for a document, and is required in XHTML.
|
|
<!DOCTYPE Doctype goes here>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title goes here</title>
</head>
<body>
</body>
</html>
|
|
Demonstration
The following demonstration shows how the script of HTML is displayed on the Web.
A woman goes to the dentist and the dentist tells her,
“You need a root canal.”
She says, “Ugh, I’d rather have another baby than a root canal!”
The dentist says, “Well make up your mind, I gotta adjust the chair.”
|