html: The HTML Document / Root element
The <html>
HTML element represents the root (top-level element) of an
HTML document, so it is also referred to as the root element. All other
elements must be descendants of this element.
- Permitted content: One
<head>
element, followed by one<body>
element. - Permitted parents: None. This is the root element of a document.
Attributes
Specific attributes
Required attributes
lang="[language-code]"
must define the main language of the document as defined by RFC 5646.
Global attributes
accesskey
Specifies a keyboard shortcut to activate or focus an element.
aria-*
Defines accessibility properties and states for assistive technologies.
class
Specifies one or more CSS class names for styling the element.
data-*
Stores custom data private to the page or application.
dir
Sets the text direction (left-to-right, right-to-left, or auto).
hidden
Hides the element from display and assistive technologies.
id
Defines a unique identifier for the element within the document.
inputmode
Hints which virtual keyboard type to display on mobile devices.
itemid
Provides a global identifier for microdata items.
itemprop
Defines a property name-value pair for microdata.
itemref
Associates properties with an item via element IDs for microdata.
itemscope
Creates a new microdata item container.
itemtype
Specifies the vocabulary URL for microdata items (like Schema.org).
lang
Specifies the primary language of the element’s content.
nonce
Provides a cryptographic nonce for Content Security Policy.
role
Defines the element’s semantic role for accessibility.
tabindex
Controls keyboard navigation order and focusability.
title
Provides advisory information displayed as a tooltip.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>My Personal Website</title>
<meta name="description" content="Welcome to my corner of the IndieWeb">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<header>
<h1>Welcome to My Personal Website</h1>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/blog">Blog</a>
<a href="/contact">Contact</a>
</nav>
</header>
<main>
<p>This is my independent space on the web, where I share my thoughts and connect with the IndieWeb community.</p>
</main>
</body>
</html>