HTML Document Structure

A well-formed HTML document generally contains <!doctype html>, an <html> root element, a <head> containing metadata, and a <body> containing document content. The lang attribute on <html> should identify the primary language of the document.

Document Skeleton
<!doctype html>\n<html lang="en">\n<head>\n  <meta charset="UTF-8">\n  <meta name="viewport" content="width=device-width, initial-scale=1.0">\n  <title>My Page</title>\n</head>\n<body>\n  <h1>Welcome</h1>\n</body>\n</html>

This structure gives browsers the required document context and includes important metadata for encoding, responsive rendering, and the page title.

Key Takeaways
  • The html element is the document root.

  • The head contains metadata while body contains page content.

Knowledge Check

Where should visible page content normally be placed?