HTML Basics- A Beginner's Guide
What HTML Actually Is
HTML stands for HyperText Markup Language. It's the skeleton of every website you've ever visited. No HTML, no web pages. It's that simple.
Stop listening to people who call it a programming language. It's not. HTML is a markup language — it structures content, nothing more. The programming happens in CSS and JavaScript.
The Anatomy of an HTML Document
Every HTML file follows the same basic structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Page Title</title>
</head>
<body>
<!-- Your content goes here -->
</body>
</html>
The <!DOCTYPE html> declaration tells browsers you're using HTML5. The <html> tag wraps everything. Inside, you have <head> (invisible stuff like title and metadata) and <body> (everything users actually see).
Essential HTML Tags You Need to Know
There are dozens of HTML tags. You only need a handful to build functional pages:
Text Structure Tags
- <h1> to <h6> — Headings. Use one <h1> per page. Never skip heading levels.
- <p> — Paragraphs. Self-closing not required.
- <strong> — Bold text for emphasis
- <em> — Italic text
- <br> — Line break (self-closing)
- <hr> — Horizontal rule (self-closing)
Links and Images
- <a href="url"> — Hyperlinks. The href attribute specifies the destination.
- <img src="path" alt="description"> — Images. Always include alt text for accessibility.
Lists
- <ul> — Unordered (bulleted) list
- <ol> — Ordered (numbered) list
- <li> — Individual list item
Containers
- <div> — Generic block container. No semantic meaning.
- <span> — Generic inline container
Understanding HTML Attributes
Attributes provide extra information about elements. They go inside the opening tag:
<a href="https://example.com" target="_blank" rel="noopener">Click me</a> <img src="photo.jpg" alt="A sunset over the ocean" width="800" height="600">
Common attributes you'll use constantly:
- id — Unique identifier for an element
- class — For grouping elements (used by CSS)
- src — Source file for images, scripts
- href — URL for links
- alt — Alternative text for images
Semantic HTML: Why It Matters
Semantic tags describe their content's meaning. They help browsers, search engines, and screen readers understand your page.
| Semantic Tag | What It Means | Old Way (Avoid) |
|---|---|---|
| <header> | Page or section header | <div class="header"> |
| <nav> | Navigation links | <div class="nav"> |
| <main> | Primary content | <div class="main"> |
| <article> | Self-contained content | <div class="article"> |
| <section> | Thematic grouping | <div class="section"> |
| <footer> | Page or section footer | <div class="footer"> |
Use semantic HTML because it makes your code readable and improves SEO. Google rewards pages that are accessible and well-structured.
Getting Started: Build Your First HTML Page
Here's your step-by-step process:
Step 1: Create the File
Open Notepad (Windows) or TextEdit (Mac). Save a new file as index.html.
Step 2: Add the Boilerplate
Copy this basic structure:
<!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> </body> </html>
The viewport meta tag makes your page responsive on mobile devices. Include it every time.
Step 3: Add Content
Put this inside your body tag:
<header>
<h1>My Website</h1>
<nav>
<a href="#about">About</a>
<a href="#contact">Contact</a>
</nav>
</header>
<main>
<section id="about">
<h2>About Me</h2>
<p>I'm learning HTML. It's not complicated once you stop overthinking it.</p>
</section>
<section id="contact">
<h2>Contact</h2>
<p>Email me at <a href="mailto:hello@example.com">hello@example.com</a></p>
</section>
</main>
<footer>
<p>© 2024 My Website</p>
</footer>
Step 4: View It
Double-click your index.html file. It opens in your browser. That's it — you've built a webpage.
Common Mistakes Beginners Make
- Forgetting to close tags — Every opening tag needs a closing tag (except self-closing ones like <br>)
- Wrong nesting order — <div><p></div></p> is wrong. Close tags in reverse order.
- No alt text on images — It's required for accessibility and SEO
- Using deprecated tags — Tags like <font>, <center>, and <marquee> are obsolete
- Skipping the DOCTYPE — Pages will still render, but quirks mode kicks in and causes problems
HTML vs. What Comes Next
HTML handles structure only. To make things look good, you need CSS. To add interactivity, you need JavaScript.
You can't build a real website with HTML alone. That's not a knock on HTML — it's just the reality. Learn HTML first, then layer in CSS, then add JavaScript when you need it.
Quick Reference: Most Used Tags
| Tag | Use |
|---|---|
| <html> | Root element |
| <head> | Metadata container |
| <body> | Visible content |
| <h1>–<h6> | Headings |
| <p> | Paragraphs |
| <a> | Links |
| <img> | Images |
| <ul>, <ol>, <li> | Lists |
| <div> | Block container |
| <span> | Inline container |
Bookmark this. You'll reference it constantly until these tags become muscle memory.
The Brutal Truth About Learning HTML
HTML is the easy part of web development. If you're struggling with HTML, web development might not be for you. That's not meant to be harsh — it's better to know now than to spend months on something that frustrates you.
If HTML makes sense and you want to keep going, move on to CSS. That's where the real work starts. HTML is just the foundation — CSS is what makes websites look like websites instead of Word documents.
Build things. Break them. Fix them. That's how you actually learn this stuff.