CSS Reset and Organizing CSS
Let me ask you something.
Have you ever started a new project, written your first few lines of CSS, and noticed things look slightly different than you expected? A gap you did not add. A font size that seems off. A margin that appeared from nowhere.
That is the browser doing things you did not ask for. And as your projects grow bigger you will also start facing a different problem — a CSS file that started at 50 lines is now 500 lines and finding anything feels like searching through a jungle.
Both of these problems have simple solutions. CSS Reset handles the browser. Good organization handles the file. Let us go through both.
Why Browsers Add Styles You Did Not Write
Every browser — Chrome, Firefox, Safari, Edge — comes with its own built-in stylesheet called the user agent stylesheet. It adds default styles to HTML elements so they look reasonable even without any CSS.
That is why an h1 is big and bold without you doing anything. Why paragraphs have space between them. Why
links are blue and underlined. Why the body has a small margin around it.
These defaults are helpful for plain HTML documents but they cause problems when you are building a designed website. Different browsers apply slightly different defaults which means your page can look slightly different in Chrome versus Firefox versus Safari without you changing a single line.
A CSS Reset solves this by stripping all those defaults away and giving you a clean consistent starting point across every browser.
The Simple Reset
You have already been using a basic reset throughout this course.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
This removes the default margins and paddings from every element and sets box-sizing to
border-box so sizing is predictable. It is the minimum reset that every project should have.
But there are a few more things worth adding for a more complete starting point.
Netflix
Unlimited movies, TV shows, and more.
Learn more
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 16px;
}
body {
font-family: "Roboto", Arial, sans-serif;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
padding: 24px;
}
img {
max-width: 100%;
display: block;
}
button {
cursor: pointer;
font-family: inherit;
}
a {
text-decoration: none;
color: inherit;
}
This is a solid modern reset. Let us go through what each part does.
*::beforeand*::after— extends the reset to pseudo-elements too. Without this,::beforeand::afterelements could still have unexpected margins or padding.line-height: 1.5onbody— sets a comfortable default line height for all text. The browser default is around 1.2 which is too tight for readable body text.-webkit-font-smoothing: antialiased— makes text render more crisply on Mac and iOS. You will not notice it on Windows but on Mac the difference is clear.max-width: 100%onimg— prevents images from ever overflowing their container. Without this an image wider than its parent will break out of it. This one line prevents a very common layout problem.display: blockonimg— images are inline by default which causes a small gap at the bottom because of how inline elements sit on the text baseline. Making them block removes that gap. This is especially noticeable inside card components.cursor: pointeronbutton— browsers do not always show the pointer cursor on buttons. This makes sure every button feels clickable.font-family: inheritonbutton— browsers use their own system font for buttons by default, ignoring whatever font you set on the body.inheritmakes buttons use whatever font the parent is using.text-decoration: noneandcolor: inheritona— removes the default blue underline from links and makes them inherit their color from the parent instead of always being blue. You can still add underlines or colors back where you want them.
Save this reset as a snippet you can paste into every new project. It takes thirty seconds to add and saves you from fighting browser defaults for the rest of the project. Once you have a reset you trust just reuse it everywhere.
Organizing Your CSS File
Now let us talk about keeping your CSS file organized as it grows.
When a project is small — 50 or 100 lines — organization does not matter much. Everything fits on one screen. But once you are at 300 or 500 lines finding things becomes genuinely difficult without a clear structure.
Here is the organization pattern that most professional developers use. It keeps everything in a logical order that anyone can navigate quickly.
/* ================================
1. DESIGN SYSTEM — Variables
================================ */
/* ================================
2. RESET — Base defaults
================================ */
/* ================================
3. BASE — Body, typography
================================ */
/* ================================
4. LAYOUT — Page structure
================================ */
/* ================================
5. COMPONENTS — Reusable pieces
================================ */
/* ================================
6. UTILITIES — Helper classes
================================ */
/* ================================
7. MEDIA QUERIES — Responsive
================================ */
Let us go through what belongs in each section.
- Design System — all your CSS variables. Colors, fonts, spacing, shadows, transitions. Everything goes here first because everything else references it.
- Reset — the universal reset and any base normalization. This always comes second because it establishes the foundation everything else builds on.
- Base — styles for raw HTML elements.
body,h1throughh6,p,a,img. These are global styles that apply everywhere without any class. - Layout — the overall page structure. The navbar, the hero, the main content area, the footer. The big structural sections.
- Components — reusable pieces. Buttons, cards, badges, forms, inputs. Things that appear multiple times in different places.
- Utilities — small single-purpose helper classes. Things like
.text-center,.hidden,.mt-sm. Optional but useful on larger projects. - Media Queries — all responsive styles at the bottom. Keeping them together at the end means you can find all your responsive overrides in one place.
Commenting Your CSS
Comments are the simplest thing you can do to make your CSS easier to navigate. A clear section header tells you exactly what is below it without reading a single line of code.
/* ================================
NAVBAR
================================ */
.navbar { ... }
.navbar #logo { ... }
.navbar .signin { ... }
/* ================================
HERO
================================ */
.hero { ... }
.hero h1 { ... }
.hero form { ... }
Those big section dividers make it immediately obvious where one section ends and the next begins. When you need to find the navbar styles you scan for the divider not through hundreds of lines of code.
For smaller notes inside sections use inline comments.
.movie-card {
position: relative; /* needed for badge positioning */
overflow: hidden; /* clips image to rounded corners */
flex-shrink: 0; /* prevents cards from squishing in flex row */
}
These explain why you made a decision, not just what the code does. Three months from now when you come back to this file you will thank yourself.
Comment the why, not the what. Writing /* sets color to red */ above
color: red adds no value — you can already see it is red. But writing /* brand color from design
system */ tells you something useful. Even better, just use a variable name like
var(--color-brand) which is self-documenting.
The Final Netflix Clone CSS Structure
Here is how our Netflix clone CSS file should be structured using everything we have learned.
Unlimited movies, TV shows, and more.
Starts at USD 2.99. Cancel anytime.
Trending Now





Here is what the organized structure gives you.
- The design system at the top — every value in one place. Change
--color-brandand the entire page updates. - The reset right after — clean consistent foundation before any styles are applied.
- Clear section headers — you can find anything in seconds. Need the movie card styles? Scan for the movie card header.
- Components grouped together — buttons, inputs, cards, notifications all have their own clearly labeled sections.
- Media queries at the very bottom — all responsive overrides in one place. No hunting through the file for where things change on mobile.
This is genuinely what professional CSS files look like. Not because the rules are arbitrary but because this structure makes the file easy to navigate, easy to update, and easy for another developer to understand.
Also Read — CSS Normalize
You have been using a CSS Reset throughout this course. Every project started with this.
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
That strips everything away. Clean slate. You build from scratch.
CSS Normalize is a different philosophy entirely. Instead of removing all defaults it fixes the inconsistencies between browsers while keeping the useful defaults intact.
Reset vs Normalize — The Real Difference
Imagine two approaches to renovating a house.
Reset is like gutting the house completely. Every wall torn down. Every floor ripped up. You start with bare concrete and build exactly what you want. Total control. Total effort.
Normalize is like a careful renovation. You keep the walls that are in good shape. You fix the ones that are cracked or uneven. You replace only what is broken. Less work. Useful starting point kept.
Neither is wrong. They just suit different situations.
With a reset you get complete control but you have to style everything yourself including things like list markers, heading sizes, and form element appearances.
With normalize you get consistent cross browser behavior with sensible defaults still in place. A h1
is still big. A ul still has bullet points. A button still looks like a button. They just
look the same across every browser.
What Normalize Actually Fixes
Here are some real examples of what normalize corrects.
- Some browsers make the
htmlelement have a different line height. Normalize fixes that. - Some browsers style the
subandsupelements differently affecting text flow. Normalize fixes that. - Some browsers add different default padding to
fieldsetelements inside forms. Normalize fixes that. - Some browsers render the
hrelement with different border styles. Normalize fixes that.
None of these are things you would ever think to reset yourself. But they can cause your page to look subtly different on Safari versus Chrome versus Firefox without you having any idea why.
How to Use Normalize
The easiest way is to link it from a CDN before your own stylesheet.
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
<link rel="stylesheet" href="style.css">
</head>
It must come before your own CSS so your styles override it where needed.
You can also install it with npm if you are working on a project with a build system.
npm install normalize.css
Which Should You Use
Here is my honest take after building a lot of projects.
For learning and personal projects the simple reset we built is perfect. It is small, you understand every line, and it gives you a clean consistent starting point.
For larger professional projects or when working with a team normalize is worth considering. It handles a lot of edge cases you would never think of and reduces cross browser surprises on elements like forms, tables, and typographic elements.
For modern projects using a framework like React or a tool like Tailwind CSS neither matters as much because these tools bring their own reset or preflight styles built in.
Never use both a reset and normalize together. They contradict each other. Reset removes defaults that normalize is trying to preserve. Pick one and commit to it. If you are not sure which just use the simple reset we built. It covers everything you need for building real projects.
Have anything to say about this lesson?
Your feedback helps improve these tutorials. If something was confusing or missing, let us know.