Browse Web basics Topics โ–ผ
โฎ Previous

HTML Basics

๐Ÿ“‚ Structure and style ๐Ÿ“˜ Lesson 1 of 5

Build the foundational structure of web pages using HTML elements, semantic tags, attributes, and hyperlinks.

Every website you visitโ€”from a simple blog to YouTube or GitHubโ€”is fundamentally built on a trio of core web technologies:

              The Three Pillars of the Web
                           โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ–ผ                   โ–ผ                   โ–ผ
     HTML                 CSS              JavaScript
 (The Skeleton       (The Clothes &       (The Muscles &
  and Content)          Styling)           Interactivity)

HTML (Hypertext Markup Language) provides the raw bones and content of the page. It tells the web browser: โ€œThis line of text is a top-level heading, this block is a paragraph, this is an image, and this is a clickable button.โ€


What Does โ€œMarkupโ€ Mean?

HTML is not a programming language like Python. It does not have for loops, variables, or functions. Instead, it is a markup language: a system of annotating plain text using tags surrounded by angle brackets (<tag>).

         Anatomy of an HTML Element
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚                                              โ”‚
  โ–ผ                                              โ–ผ
<p class="intro">Welcome to Roadmappro!</p>
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚        โ–ผ                  โ–ผ             โ”‚
โ”‚    Attribute           Content          โ”‚
Opening Tag                           Closing Tag
  • Opening Tag (<p>): Marks where the element begins.
  • Attributes (class="intro"): Key-value metadata providing extra information to the browser.
  • Content: The text or nested elements inside.
  • Closing Tag (</p>): Marks where the element ends (notice the forward slash /).

Some elements do not have closing tags because they cannot hold text content. These are called void or self-closing elements, such as <img src="..." alt="...">, <br>, and <input>.


The Standard HTML5 Boilerplate

Every production web page begins with this foundational skeleton:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My First Web Page</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
    <p>This is my first website built from first principles.</p>
  </body>
</html>
  • <!DOCTYPE html>: Tells modern browsers to render the document using the modern HTML5 standard.
  • <html lang="en">: The root element wrapping the entire document.
  • <head>: Contains invisible metadata about the page (character encoding, mobile viewport settings, stylesheet links, and the tab <title>).
  • <body>: Contains all visible content displayed on the screen.

Core Everyday Elements

1. Headings (<h1> to <h6>)

Headings structure your document into a clear hierarchy:

<h1>Main Topic of the Page</h1>
<h2>Major Subheading</h2>
<h3>Detailed Subsection</h3>

[!TIP] Always maintain a logical heading hierarchy. Every page should have exactly one <h1> representing the main topic. Never skip levels (such as jumping directly from <h1> to <h4>) just to make text visually smallerโ€”use CSS for sizing instead!

2. Paragraphs and Inline Text

<p>
  Learning web development is exciting. You can make text 
  <strong>bold for importance</strong> and <em>italicized for emphasis</em>.
</p>

3. Ordered and Unordered Lists

<!-- Unordered (bullet points) -->
<ul>
  <li>HTML for structure</li>
  <li>CSS for styling</li>
  <li>JavaScript for behavior</li>
</ul>

<!-- Ordered (numbered list) -->
<ol>
  <li>Write the markup</li>
  <li>Style with CSS</li>
  <li>Deploy to production</li>
</ol>

Hyperlinks connect the web together:

<!-- External link that opens in a new browser tab -->
<a href="https://developer.mozilla.org" target="_blank" rel="noopener">
  Visit MDN Web Docs
</a>

<!-- Image element with required alt text -->
<img src="/images/avatar.png" alt="Profile picture of Ada" width="120" height="120" />

Semantic HTML: Stop Building โ€œDiv Soupsโ€

Before modern HTML5, developers wrapped everything in generic <div> tags: <div class="nav">, <div class="footer">.

Modern web standards require Semantic HTML: using tags that describe the meaning of their content:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  <header>                    โ”‚
โ”‚            <nav> Navigation </nav>           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                   <main>                     โ”‚
โ”‚  <article>                    <aside>        โ”‚
โ”‚    <h1>Post Title</h1>        Sidebar info   โ”‚
โ”‚    <p>Content...</p>                         โ”‚
โ”‚  </article>                                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                  <footer>                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Why Semantic HTML Matters

  1. Accessibility (a11y): Blind and visually impaired users navigating with screen readers can jump directly to <nav> or <main>.
  2. Built-in Keyboard Support: A real <button>Click</button> can be activated with the Tab and Enter keys on a keyboard. A <div onclick="..."> cannot, locking out keyboard users!
  3. SEO (Search Engine Optimization): Search engines like Google rely on semantic tags to index your article content accurately.

Common Traps to Avoid

  1. Forgetting Closing Tags: Leaving tags unclosed (like <p> or <div>) causes browser layout bugs where subsequent elements inherit unintended styling.
  2. Missing alt on Images: Every <img> tag must include an alt attribute. If an image is purely decorative, specify alt="" so screen readers ignore it gracefully.
  3. Using <div> Instead of <button>: Never create clickable buttons out of styled <div> tags. Always use <button type="button">.
  4. Using Heading Tags for Sizing: Donโ€™t pick <h3> just because you want medium-sized text. Choose tags based on structural hierarchy, and control size using CSS.

Next Steps

Raw HTML looks plain and unstyled in a browserโ€”black text on a white background with default blue links.

Learn how to bring your pages to life with colors, typography, and beautiful layouts using CSS.

Test your understanding of HTML Basics

Quick interactive practice questions with instant feedback.

Take Quiz โ†’