Web Development · Module 2 · Lesson 11 min read

Document Structure

What HTML is

HTML (HyperText Markup Language) describes the structure and meaning of content using elements written as tags: <p>This is a paragraph</p>. Opening tag, content, closing tag.

The basic page

HTML
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Page</title>
  </head>
  <body>
    <!-- visible content goes here -->
  </body>
</html>
  • <!DOCTYPE html> tells the browser to use modern standards mode.
  • lang="en" helps screen readers and search engines.
  • <head> holds information about the page (title, styles, meta tags).
  • The viewport meta tag is essential for mobile-friendly pages.
  • <body> holds everything the user sees.

Attributes

Extra information inside the opening tag: <a href="/about" target="_blank">. Common ones: id, class, href, src, alt, title.

Rules to remember

  • Nest tags properly: <b><i>text</i></b>, not <b><i>text</b></i>.
  • Some elements are empty (no closing tag): <img>, <br>, <input>, <meta>.
  • Comments: <!-- like this -->.
  • Whitespace is collapsed: many spaces show as one.

Example

HTML
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My First Page</title>
  </head>
  <body>
    <h1>Welcome to my site</h1>
    <p>This is my <strong>first</strong> web page.</p>
    <!-- Comments are not shown on the page -->
  </body>
</html>