Start Your Next Web Project Right: The Two First Steps
đ Start Your Next Web Project Right: The Two First Steps
Youâve just typed git init and opened a blank index.html. The excitement of a new codebase is high. Before you write a single <div>, the first two decisions you make will set the foundation for the entire project.
Get these right, and youâll save yourself (and your team) from countless headaches. Get them wrong, and youâll be fighting your own code for months.
Letâs talk about the two non-negotiable first steps for any new project: implementing a CSS Reset and committing to Semantic HTML.
đ¨ Step 1: Tame the Chaos with a CSS Reset
The Problem: Every web browser (Chrome, Firefox, Safari) has its own built-in stylesheet, called a user-agent stylesheet. This is why a default <h1> has a certain size and margin, and why a <ul> has a bullet point.
The problem? They are all slightly different.
Chromeâs default margin on a <p> tag might be 16px, while Firefoxâs might be 1em. This means your âpixel-perfectâ site in development will look subtly broken on your teammateâs machine or your clientâs browser. Youâll spend your time writing styles to âfixâ or âundoâ the browserâs defaults instead of building your design.
The Solution: A CSS Reset is a small, simple stylesheet you include before all your other styles. Its only job is to remove or normalize all these inconsistent default styles.
It gives you a 100% consistent, predictable âclean slateâ to build upon.
A Modern, Minimal CSS Reset
You donât need a huge, complicated file. For most modern projects, a few lines are all it takes. Here is a very popular and effective modern reset you can use:
/*
A simple, modern CSS reset.
This goes in your main CSS file, right at the top.
*/
/* 1. Use a more intuitive box-sizing model on all elements. */
*, *::before, *::after {
box-sizing: border-box;
}
/* 2. Remove default margin and padding from all elements. */
* {
margin: 0;
padding: 0;
}
/* 3. Allow percentage-based heights */
html, body {
height: 100%;
}
/* 4. Set sensible defaults for media (images, videos) */
img, picture, video, canvas, svg {
display: block;
max-width: 100%;
}
/* 5. Remove built-in form typography styles */
input, button, textarea, select {
font: inherit;
}
How to use it: Place this at the very top of your main styles.css file. Now, when you add an <h1> or a <p>, it will have no margin, no padding, and will use the border-box model. You are in complete control from the start.
đď¸ Step 2: Build a Strong Blueprint with Semantic HTML
With a clean slate, itâs time to build the structure.
The Problem: It is possible to build an entire website using only <div> and <span> tags. Many developers fall into this trap, creating âdiv-soup.â
Bad Example (Non-Semantic):
<div id="header">
<div class="logo">My Site</div>
<div class="nav">...</div>
</div>
<div class="main-content">
<div class="article">...</div>
<div class="sidebar">...</div>
</div>
<div id="footer">...</div>
This code tells you nothing. It has no meaning. A search engine, a screen reader, or a new developer has no idea what âmain-contentâ is or how it relates to âsidebar.â
The Solution: Semantic HTML means using HTML elements for their meaning, not for how they look.
Good Example (Semantic):
<header>
<h1>My Site</h1>
<nav>...</nav>
</header>
<main>
<article>...</article>
<aside>...</aside>
</main>
<footer>...</footer>
This is clean, readable, and immediately communicates the structure of the page.
Why Semantic HTML is Non-Negotiable
This isnât just about âclean code.â It has three massive, practical benefits.
1. âż Accessibility (A11y)
This is the most important reason. Users who are blind or have low vision use screen readers to navigate the web. These tools donât âseeâ your page; they read the code.
- When you use
<nav>, the screen reader announces, âNavigation,â and the user can choose to jump to it or skip it. - When you use
<main>, you create a âlandmark.â This allows a user to instantly skip the header and navigation and jump directly to the main content. - If you just use
<div class="main-content">, the user has to listen to your entire header and navigation on every single page just to find out whatâs on it.
Using semantic HTML is the single most important thing you can do to make your site accessible.
2. đ SEO (Search Engine Optimization)
Googleâs crawlers behave a lot like screen readers. They use your HTML structure to understand what your content is about. Using <article>, <h1>, and <main> clearly tells Google what the most important content on your page is, which helps you rank higher.
3. đ¤ Maintainability
Six months from now, when you or a new teammate looks at the code, the semantic version is instantly understandable. <footer> is obvious. div class="f-wrap" is not. Itâs self-documenting code.
Conclusion: Your Foundation for Success
Itâs tempting to jump straight into the âfun stuffâ of building components and writing flashy CSS. But a house built on a shaky foundation will always have problems.
- Start with a CSS Reset: You get visual consistency across all browsers.
- Build with Semantic HTML: You get accessibility, SEO, and maintainability for free.
These two steps take almost no extra time, but they set a professional standard for your codebase and prevent a future filled with bugs, accessibility lawsuits, and unreadable code.