Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Basic Document Structure | HTML Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. HTML Course

Lesson 23 of 55

·HTML

Basic Document Structure

6 min

Course progress42%

What you'll learn

Keep these ideas in mind as you work through the lesson.

5 points
  • Doctype declaration and standards‑mode
  • Root `<html>` element and the `lang` attribute
  • Essential `<meta>` tags (`charset`, `viewport`)
  • Title tag importance for SEO
  • Semantic vs. generic container elements

Basic Document Structure

Every HTML document follows the same hierarchy:

<!DOCTYPE html>
<html lang='en'>
  <head>
    <meta charset='UTF-8' />
    <meta name='viewport' content='width=device-width, initial-scale=1' />
    <title>Page Title</title>
    <!-- CSS, favicons, meta tags go here -->
  </head>
  <body>
    <!-- Visible content goes here -->
  </body>
</html>

Key sections

  • <!DOCTYPE html> – Triggers standards‑mode rendering across browsers.
  • <html> – Root element; the lang attribute declares the page language for assistive technologies and SEO.
  • <head> – Holds metadata, external resources, and the title.
  • <meta charset='UTF-8'> – Must be the first meta tag; it sets the character encoding to UTF‑8.
  • <meta name='viewport'> – Essential for responsive design on mobile devices; defines the logical viewport width.
  • <title> – Shows up in the browser tab, bookmark bar, and search‑engine results.
  • <body> – Contains everything displayed to the user.

Best practices

  1. Keep <head> lightweight. Load critical CSS early, defer non‑essential scripts.
  2. Prefer semantic landmarks (<header>, <main>, <footer>) over generic <div> containers.
  3. Declare the document language (lang) as early as possible for SEO and screen readers.
  4. Place the charset meta tag first to avoid rendering glitches.

Tip: The <title> should be under 60 characters to prevent truncation in search results.


Quick checklist for document structure

  • Doctype present? ✅
  • <html lang='…'> defined? ✅
  • <meta charset='UTF-8'> first in <head>? ✅
  • <meta name='viewport'> included? ✅
  • Semantic sections (<header>, <main>, <footer>) used? ✅

If any of the above are missing, add them now before moving on.

Make it stickPractice what you've learned1 quiz · 2 practical tests · Optional activities from HTML CourseBrowse activities
Previous lessonSEO Fundamentals – Meta Tags and TitleContinue to lesson 24Metadata – Charset, Viewport, HTTP‑EquivBack to HTML Course curriculum