Introduction
HTML gives the browser the skeleton; CSS gives it the skin. If your pages look “unstyled” or wildly off after a change, you’re usually fighting the boundary between structure (HTML) and presentation (CSS), not the browser being “broken.”
Quick questions people usually ask: What does HTML actually do? What does CSS actually do? Why do my styles not apply? and How do I fix layout issues without guesswork?
According to the MDN documentation on HTML basics, HTML is the language used to structure content on the web. For styling, the MDN guide on how CSS works describes how CSS targets elements to change their appearance. Together, they form the foundation of modern web development.
By the end, you’ll be able to read an HTML document, understand what CSS selectors are targeting, and debug the most common “CSS isn’t doing anything” and “my layout broke” problems.

Table of Contents
What is HTML?
HTML (HyperText Markup Language) is the markup language that tells the browser what content exists and how it’s organized. It’s not primarily a styling tool—its job is structure and semantics.
A simple mental model: HTML builds a tree.
- Elements (like
<h1>,<p>,<nav>,<section>) represent content parts. - Attributes (like
class,id,href) add details used for styling, scripting, accessibility, and linking. - Heading levels and landmarks help browsers and assistive technologies understand the page.
If you’ve ever tried to “fix” spacing with a bunch of random CSS guesses, there’s a fair chance the underlying HTML structure is also doing something unexpected—like missing a wrapper, using the wrong heading element, or applying classes to the wrong element.
What is CSS?
CSS (Cascading Style Sheets) is the language that controls how HTML is presented: layout, color, typography, spacing, and responsive behavior.
CSS works by selecting elements and applying rules. The most important parts are:
- Selectors (e.g.,
.card,#main,nav a) choose which elements to style. - Declarations (e.g.,
color: #333;) state what to change. - The cascade decides what wins when multiple rules apply (order, specificity, and source order all matter).
Debugging CSS is basically answering one question: is my selector matching what I think it matches? If the answer is “no,” the rest of your changes are just creative writing.
For a deeper foundation, see MDN’s box model explanation—most layout confusion reduces to misunderstanding how margins, borders, padding, and width/height interact.
If you want the “spec-level” mental model behind the rules, the W3C CSS Cascading and Inheritance Module Level 5 is the canonical place to start.
How they work together
HTML and CSS are separate layers, but the browser merges them into a single rendered result. Here’s the usual pipeline:
- HTML is parsed into the DOM (document structure).
- CSS is parsed into rules.
- The browser matches CSS selectors against DOM elements.
- Computed styles produce the final layout and painting.
Because CSS selectors rely on HTML structure and attributes, small HTML changes can cause big visual changes. For example:
- Renaming or moving a
classcan make a selector stop matching. - Changing from a
<div>wrapper to a different element can affect default display behavior (unless overridden). - Applying a class to a parent instead of a child changes which elements the selector targets.
Practical debugging steps (the “rule out boring stuff first” version)
- Inspect the element in DevTools and check the “Styles” pane to see whether rules are matched.
- Confirm the selector target (class/id names, nesting, and whether the element actually exists in the live DOM).
- Check the cascade: look for overridden properties (often due to specificity or later rules).
- Validate layout basics: box model, display type (
block,flex,grid), and container sizing.
If you’re building something from scratch—or restoring an existing layout—this “check matching first, then cascade, then box model” routine saves time.
Example: turning structure into a styled component
Suppose your HTML defines a card:
<article class="card">
<h2>Title</h2>
<p>Summary text.</p>
</article>
CSS then targets it:
.card { padding: 16px; border-radius: 12px; }
.card h2 { margin-top: 0; }
HTML decides what the card is (an <article> with a heading and paragraph). CSS decides how it looks (spacing, typography, borders). Neither part should be doing the other one’s job.
Conclusion
HTML and CSS work best when you keep responsibilities clean: HTML structures content and semantics, while CSS presents that structure. When something looks wrong, don’t start by rewriting styles blindly—start by confirming the HTML element you think you’re styling is actually the one your CSS selectors are matching.
If you want more background on site structure and related topics, browse our blog for additional web-development explainers, or see about for the broader mission behind this resource desk.
First diagnostic step: open DevTools, select the broken element, and check whether the CSS rules you expect are actually being applied.
Image note: The inline image above is used as a visible placeholder from the site’s media library.