Computers & ProgrammingHTML/XHTMLWeb Development

HTML Html Element

Within an HTML page, there is a very important element called html. The <html> tag instructs the browser that this is an HTML document. The <html> element is also known as the root element.

The <html> element is the container for all other HTML elements in the HTML document except for the <!DOCTYPE> declaration. All other HTML elements are contained within a start and an end <html> tag as shown in the following example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Computers R Us</title>
    <meta name="description" content="Get Computers, servers and laptops on Sale!!!" />
    <meta name="keywords" content="computers,servers,laptops" />
    <link href="styles/master.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        table {
            border:0px solid black;
        }
    </style>
    <script type="text/javascript">
        ..content..
    </script>
</head>
<body>
    <h1>Main heading</h1>
</body>
</html>

Required Attributes

If the DOCTYPE is set to XHTML, then the xmlns attribute is required. For HTML, it is invalid. The required attribute is added as shown in this example: <html "xmlns=http://www.w3.org/1999/xhtml">

AttributeValueDescriptionDTD
xmlnshttp://www.w3.org/1999/xhtmlSpecifies the namespace to use only for XHTML documents.STF

Optional Attributes

AttributeValueDescriptionDTD
dirrtl, ltrSpecifies the text direction for the content in an element.STF
langlanguage_codeSpecifies a language code for the content in an element.STF
xml:langlanguage_codeSpecifies a language code for the content in an element, in XHTML documents.STF

Leave a Comment

Your email address will not be published.

Scroll to Top