# CSS Fundamentals

> Control how pages look with selectors, the cascade, the box model, units and custom properties. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/full-stack/css
Last updated: 2026-11-28

Control how pages look with selectors, the cascade, the box model, units and custom properties.

Beginner · about 8 hours · difficulty 2/5

Learn first: [Semantic HTML](https://www.internhack.in/roadmaps/tracks/full-stack/html)

Even if you later use Tailwind, you are still writing CSS. Utility classes only make sense once you understand what they compile to.

### The core model

- **Selectors and specificity**: why one rule beats another. Prefer classes; avoid IDs and !important for styling.
- **The cascade and inheritance**: color and font inherit; margin and border do not.
- **Box model**: content, padding, border, margin. Set box-sizing: border-box globally.
- **Units**: px for borders, rem for type and spacing, % and viewport units for layout.

### Modern CSS you should use

- **Custom properties** (CSS variables) for colours and spacing, which also make dark mode easy.
- **Pseudo-classes** like hover, focus-visible and disabled for interactive states.
- **Transitions** for small, purposeful motion.

### Debugging

Use DevTools to inspect an element, see which rules apply, which are crossed out and why, and edit values live. This one habit saves hours.

### Pitfalls

- Fighting specificity with more and more specific selectors instead of simplifying.
- Removing focus outlines without a replacement, which hides where keyboard users are.
- Hard-coding colours everywhere instead of using variables.

You are ready to move on when you can style a card component from a design screenshot and explain, using DevTools, why each rule applies.

## Key concepts

- **Selectors and specificity**
- **Cascade and inheritance**
- **Box model**
- **Units: px, rem, %, vw**
- **Custom properties**
- **Pseudo-classes and states**
- **Transitions**
- **DevTools styles panel**

## Mini project

Style your fest registration page with a colour theme defined in CSS variables, clear hover and focus states, and a light and dark mode toggle driven by a single class on the body.

## Check yourself

Two rules set the colour of the same button and the one you expected does not win. What three things decide which rule applies?

## Free resources

- [CSS](https://developer.mozilla.org/en-US/docs/Web/CSS) (MDN)
- [Learn CSS](https://web.dev/learn/css) (web.dev)
- [CSS-Tricks](https://css-tricks.com/) (CSS-Tricks)

Previous: [Semantic HTML](https://www.internhack.in/roadmaps/tracks/full-stack/html) · Next: [Flexbox, Grid and Responsive Design](https://www.internhack.in/roadmaps/tracks/full-stack/responsive-layout)

## More in HTML, CSS and Accessible Layout

- [Semantic HTML](https://www.internhack.in/roadmaps/tracks/full-stack/html)
- [CSS Fundamentals](https://www.internhack.in/roadmaps/tracks/full-stack/css)
- [Flexbox, Grid and Responsive Design](https://www.internhack.in/roadmaps/tracks/full-stack/responsive-layout)
- [Web Accessibility Basics](https://www.internhack.in/roadmaps/tracks/full-stack/accessibility)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Full-Stack Developer Roadmap](https://www.internhack.in/roadmaps/tracks/full-stack)
