techTreksBooks

How webpages work

What HTML does

  • HTML (HyperText Markup Language) gives structure and meaning to a page.
  • Browsers read HTML from top to bottom and turn tags into elements you can see and interact with.
  • Good HTML makes content readable even before any CSS is added.

The essential document shape

Every page should start the same way:

<!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>
    <!-- Content goes here -->
  </body>
</html>
  • <!DOCTYPE html> tells the browser to use modern HTML.
  • <html> wraps the whole page; add lang="en" for accessibility.
  • <head> holds the title and settings; <body> holds what people see.

Block vs inline elements (quick view)

  • Block elements (e.g. <h1>, <p>, <div>, <header>) start on a new line and stretch to fill the available width.
  • Inline elements (e.g. <a>, <strong>, <img>, <span>) sit inside a line of text without forcing a new line.
  • Use blocks to group sections; use inline elements for small pieces inside those sections.