The Complete CSS Foundations Playground

1. Selectors: How to Target Elements

Selectors are the foundation of CSS. They are patterns that "select" the HTML elements you want to style. This is how you tell the browser *what* to change.

CSS Editor

Live Preview

2. The Box Model

This is the most important concept in CSS. Every HTML element is just a rectangular box. The "Box Model" describes how this box is built.

CSS Editor

Live Preview

3. Typography: Styling Text

Styling text is what makes a website readable and beautiful. These are the most common properties for controlling text.

CSS Editor

Live Preview

4. Positioning

The position property lets you take elements out of the normal "document flow" to place them in specific spots.

CSS Editor

Live Preview

5. display: flex (Flexbox)

Flexbox is a modern, powerful 1-Dimensional (1D) layout system. It's designed to align and distribute items in a single row OR a single column.

Analogy: Think of it as a smart bookshelf. You can tell it to stack books vertically (flex-direction: column) or line them up horizontally (flex-direction: row). You can also tell it how to space them out (justify-content).

CSS Editor

Live Preview

6. display: grid (CSS Grid)

CSS Grid is the most powerful layout system. It is 2-Dimensional (2D), meaning it controls layout in both rows AND columns at the same time.

Analogy: Think of it as a spreadsheet or a chessboard. You define the grid (e.g., "I want 3 columns and 2 rows"), and then you place your items into the "cells" you've created.

CSS Editor

Live Preview

7. Responsive Design (Media Queries)

Responsive design is the practice of making your website look good on all devices, from tiny phones to wide-screen desktops. We use Media Queries to apply different CSS rules based on the screen size.

The code @media (max-width: 600px) { ... } means: "If the browser window is 600px wide or *less*, apply these special rules."

Tip: Try resizing your browser window (or the preview pane below, if you can) to see the changes take effect!

CSS Editor

Live Preview