XHTML » Tags » html

Syntax:
<html> ... </html>

The html tag informs the browser that this is an HTML encoded program. The html opening and closing tags delimit the start and stop of the document.

The only tag that can precede the opening html tag is the DOCTYPE tag. It is used to select the XHTML DTD (Document Type Definition) that sets the rules and syntax for the XHTML document.
 
A well-formed XHTML document must contain properly nested and closed html, head, title, and body tags.
 
Although it is not a requirement, it is strongly recommended that the opening html tag contain information defining the language being used for both the XHTML document and for XML. This is set respectively with the lang and the xml:lang attributes. In addition, the html tag should also contain the XML namespace declaration (xmlns). This is demonstrated for English with the following code.
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
The separate closing tag is mandatory.
 

Examples

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML html Tag Example</title>
</head>
<body>
body content goes here...
</body>
</html>
Output:
body content goes here...
Explanation:

This example demonstrates the basic structure of an XHTML program.

Language(s): XHTML

See Also: