HTML Basics
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>
4. Links (<a>) and Images (<img>)
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
- Accessibility (a11y): Blind and visually impaired users navigating with screen readers can jump directly to
<nav>or<main>. - Built-in Keyboard Support: A real
<button>Click</button>can be activated with theTabandEnterkeys on a keyboard. A<div onclick="...">cannot, locking out keyboard users! - SEO (Search Engine Optimization): Search engines like Google rely on semantic tags to index your article content accurately.
Common Traps to Avoid
- Forgetting Closing Tags: Leaving tags unclosed (like
<p>or<div>) causes browser layout bugs where subsequent elements inherit unintended styling. - Missing
alton Images: Every<img>tag must include analtattribute. If an image is purely decorative, specifyalt=""so screen readers ignore it gracefully. - Using
<div>Instead of<button>: Never create clickable buttons out of styled<div>tags. Always use<button type="button">. - 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.