Stop 01 · Web & JavaScript FoundationsTopics · 4/10

HTML and CSS Basics

Part of the MERN Stack Roadmap

In short

Every React component ends up as HTML on the screen, styled by CSS. If you understand tags, the box model and Flexbox, your MERN screens will look clean instead of broken.

React renders HTML elements and you style them with CSS, so you need semantic tags, forms, the box model, Flexbox and responsive layouts before building MERN screens.

The jaadu stacks plain wooden blocks into a little house, then happily paints the walls and arranges tiny furniture in neat rows.

Think of it like this

Building and decorating a house

HTML is the structure: walls, doors and rooms, each with a clear purpose. CSS is the paint, furniture placement and spacing. You can repaint a room without knocking down a wall, just like you can restyle a page without touching its HTML.

Watch it happen

A page is a tree of elements

body
header
nav
main
form
input
button
footer

1/4Everything visible sits inside body.

The big ideas

What you need to know

Semantic tags

Use header, nav, main, section, button and label instead of div for everything. They carry meaning and help accessibility.

The box model

Every element is a box: content, padding, border, then margin. Set box-sizing: border-box so widths behave as you expect.

Flexbox for layout

display: flex lines children up in a row or column. justify-content and align-items control spacing and alignment.

Responsive design

Most users in India are on phones. Design mobile first and use media queries to adjust for wider screens.

See it in code

Walk through the code

html
1<main class="cards">2  <article class="card">3    <h2>Masala Chai</h2>4    <p>Rs 40</p>5    <button type="button">Add to cart</button>6  </article>7</main>8 9<style>10  * { box-sizing: border-box; }11  .cards { display: flex; flex-wrap: wrap; gap: 16px; padding: 16px; }12  .card { flex: 1 1 200px; padding: 12px; border: 1px solid #ddd; border-radius: 8px; }13  @media (min-width: 768px) { .cards { padding: 32px; } }14</style>

1/4Semantic structure: a main region holding an article per product, with a real button element.

A responsive row of product cards. In React this same markup becomes JSX with className instead of class.

Save yourself the pain

Common mistakes

Oops

Using a div with an onclick for every clickable thing.

Do this instead

Use a button element. It works with the keyboard and screen readers for free.

Oops

Setting fixed pixel widths like width: 1200px on containers.

Do this instead

Use max-width, percentages and flex-wrap so the layout fits small phone screens.

Oops

Forgetting a label for form inputs.

Do this instead

Pair each input with a label using for and id. Clicking the label focuses the input.

Your mission

Build a mini menu page

~30 min

Quick check

An element has width: 200px, padding: 10px and border: 2px with box-sizing: border-box. How wide is it on screen?

Go deeper

  1. 1Build one responsive page with a navbar, a grid of cards and a contact form in plain HTML and CSS.
  2. 2Get comfortable with Flexbox, since nearly every React layout uses it.
  3. 3If HTML and CSS are brand new, spend a week on them before moving on.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge