HTML Coding Basics- Your First Steps in Web Development
What HTML Actually Is (And What It Isn't)
HTML stands for HyperText Markup Language. It's the skeleton of every webpage you've ever visited. No HTML, no website. That's just how it works.
But here's what most beginners get wrong: HTML isn't a programming language. It's a markup language. You use it to structure content, not build logic. If you want behavior—click handlers, animations, data processing—that's JavaScript's job.
HTML tells the browser what things are. This is a heading. This is a paragraph. This is a link. The browser figures out how to display it.
The Basic Structure of an HTML Document
Every HTML page follows the same basic template. Memorize this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Page Title</title>
</head>
<body>
<!-- Your content goes here -->
</body>
</html>
The <!DOCTYPE html> declaration tells the browser you're using modern HTML5. The <head> section holds metadata—things the browser and search engines need. The <body> section is where your visible content lives.
Essential HTML Tags You Need to Know
You don't need to memorize every HTML tag. You need to know these core ones:
- <h1> through <h6> — Headings. H1 is the main title. H2 is a section header. Don't skip heading levels for styling purposes.
- <p> — Paragraphs. Each block of text gets its own tag.
- <a href=""> — Links. The href attribute holds the destination URL.
- <img src="" alt=""> — Images. Always include alt text for accessibility.
- <div> — Generic container. Used for grouping and styling.
- <span> — Inline container. For styling small portions of text.
- <ul> and <ol> — Unordered (bulleted) and ordered (numbered) lists.
- <li> — List items. Must be inside ul or ol tags.
Tags Always Come in Pairs (Mostly)
Most HTML tags have an opening tag and a closing tag. The closing tag has a forward slash before the tag name:
<p>This is a paragraph.</p>
Some tags are self-closing. These are called void elements:
<img /><br /><hr /><input />
Attributes: How You Configure Tags
Tags have attributes that provide additional information. They go inside the opening tag:
<a href="https://example.com" target="_blank" rel="noopener">Click me</a>
Common attributes:
- href — Where a link goes
- src — Where an image or script comes from
- alt — Alternative text for images
- class — For CSS styling
- id — Unique identifier for JavaScript and linking
- style — Inline CSS (avoid this in production)
Semantic HTML: Why It Matters
You can build an entire website using only <div> tags. It will work. But it's stupid.
Semantic HTML uses tags that describe their content's purpose:
<header>— Page or section header<nav>— Navigation links<main>— Primary content<article>— Self-contained content<section>— Thematic grouping<aside>— Sidebar content<footer>— Page or section footer
Search engines weight content in semantic tags. Screen readers use them to help visually impaired users navigate. Your code becomes readable to other developers. There's no downside.
Common HTML Mistakes Beginners Make
These will bite you if you're not careful:
- Unclosed tags — Every opening tag needs a closing tag (except void elements). The browser will guess what you meant, and it's usually wrong.
- Wrong tag nesting —
<p><strong>text</p></strong>is invalid. Tags must close in the order they opened. - Using heading tags for size — H1 isn't "big text." It's your main title. Use CSS for styling.
- Forgetting the doctype — Without it, browsers switch to "quirks mode" and render inconsistently.
- Missing alt text — Your image breaks? Alt text shows instead. Also, it's required for accessibility.
HTML5 Elements Comparison
| Element | Purpose | Inline/Block | Semantic |
|---|---|---|---|
| <div> | Generic container | Block | No |
| <span> | Inline text container | Inline | No |
| <article> | Self-contained content | Block | Yes |
| <section> | Thematic grouping | Block | Yes |
| <aside> | Related content/sidebar | Block | Yes |
| <figure> | Self-contained media with caption | Block | Yes |
Your First HTML Page: Getting Started
Here's exactly what you do:
- Open Notepad (Windows) or TextEdit (Mac)
- Copy the basic HTML template above
- Save the file as
index.html - Open it in any browser by double-clicking
Now add some content inside the <body> tag:
<body>
<header>
<h1>My First Website</h1>
</header>
<main>
<h2>About Me</h2>
<p>I'm learning HTML and it's going fine.</p>
<h3>My Skills</h3>
<ul>
<li>HTML basics</li>
<li>Not much else yet</li>
</ul>
<img src="placeholder.jpg" alt="A placeholder image">
<p>Want to know more? <a href="https://example.com">Visit my blog</a>.</p>
</main>
<footer>
<p>© 2024 My Site</p>
</footer>
</body>
Save and refresh your browser. That's it. You've built a webpage.
Where to Go From Here
HTML is the starting point, not the destination. You'll need:
- CSS — Makes things look decent. HTML handles structure; CSS handles style.
- JavaScript — Adds interactivity. Buttons that work, forms that validate, content that changes without page reloads.
- DevTools — Every browser has them. Right-click any page, select "Inspect." You'll see the HTML structure and can play with it in real-time.
MDN Web Docs (developer.mozilla.org) is the best HTML reference you'll find. Use it.
The Brutal Truth
HTML is easy. That's the point. You can learn the basics in a day. But good HTML—semantic, accessible, maintainable—that takes practice.
Most "HTML tutorials" teach you to slap divs everywhere and call it done. Don't do that. Learn semantic markup from the start. It's not harder, and it makes everything else easier.