Structure vs. Style
Picture a house being built. First the framing crew puts up the studs, walls, and rooms — that's the skeleton that says "this is a bedroom, this is a hallway, this is the front door." Later, a completely different crew comes through with paint, tile, and light fixtures — that's what makes the house feel like your house instead of a bare frame. Building a web page works the same way: HTML is the framing crew, and CSS is the paint-and-tile crew. Confuse the two jobs and you get a house where the plumbing is painted blue because someone thought that's what "style" meant.
💡 The Bottom Line
HTML describes what something is — a heading, a paragraph, a list, a button. CSS describes what it looks like — color, spacing, font, layout. Keep those two jobs separate and both your markup and your styling stay easy to read, reuse, and change.
The anatomy of an HTML document
Every HTML page starts from the same skeleton. It's boilerplate, but each piece has a job:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>My Page</title>
</head>
<body>
<h1>Welcome</h1>
<p>This is a paragraph of real content.</p>
</body>
</html>
<!DOCTYPE html> tells the browser "parse this as modern HTML." The
<head> holds metadata the visitor never sees directly — the page title, character
encoding, links to stylesheets. The <body> holds everything the visitor actually
looks at. Nothing in this skeleton says anything about color or spacing — that's not HTML's job.
🙋 There Are No Dumb Questions
Q: Can't I just style things directly in HTML with a style="" attribute
and skip CSS files entirely?
A: You technically can, but it defeats the whole point of separating structure from style. If
every element carries its own inline styling, changing your site's look means editing every
single element instead of one shared stylesheet. Inline styles are fine for a rare one-off
tweak, not as your main styling strategy.
Semantic tags vs. divs
HTML gives you two ways to mark up a section of a page: a generic box, or a tag that describes what the box means.
<!-- Generic — says nothing about what this is -->
<div class="top-section">
<div class="site-name">My Blog</div>
</div>
<!-- Semantic — says exactly what this is -->
<header>
<h1>My Blog</h1>
</header>
Both can look identical once CSS is applied. But <header>, <nav>,
<main>, <article>, and <footer> tell screen readers,
search engines, and other developers what each part of the page means — not just how it's
boxed up. A <div> is a blank box with no built-in meaning; reach for a semantic tag
first, and only fall back to <div> when nothing semantic fits.
⚠️ Watch Out
"Div soup" — wrapping everything in nested <div>s with no semantic tags at all
— is one of the most common beginner habits. It works visually, but it makes the page harder for
assistive technology to navigate and harder for you to read six months later. If you're about to
write <div class="header">, ask whether <header> would do the same
job for free.
Where CSS enters the picture
CSS (Cascading Style Sheets) attaches to that HTML skeleton and answers "how should this look?"
You link a stylesheet once in the <head>, and it can restyle every matching element
on the whole page:
<head>
<link rel="stylesheet" href="style.css" />
</head>
/* style.css */
h1 {
color: #1a2b4c;
font-family: Georgia, serif;
}
One rule, and every <h1> on the page updates. That's the payoff of keeping structure
and style apart: change the CSS file and the whole site's look updates without touching a single
HTML tag.
🔧 Try It Yourself
Take a page you've seen recently — a blog post, a product page, anything. Sketch its
structure using only semantic tags (header, nav, main,
article, footer) with no styling in mind at all. Then, separately, list
three visual choices (colors, fonts, spacing) you'd make for it. Notice how the two lists never
overlap — that's structure and style staying in their own lanes.
✅ Quick Check
Why prefer <header> over <div class="header">?
Next up: once you've got HTML elements on the page, CSS treats every single one of them as a box — and understanding exactly how that box is measured is the difference between layouts that behave and layouts that mysteriously overflow. That's the box model.