CSS Flexbox Playground
Pick flex container properties and the layout in the result area updates instantly, with the ready CSS shown below. Click an item to set its flex-grow, flex-basis, order or align-self.
Use cases
- Understanding what each flexbox property does by changing it and seeing the result
- Finding the right alignment for a menu, a row of cards or a centered block
- Copying the ready CSS, or opening the example in the HTML Editor to keep building
FAQ
Flexbox (CSS Flexible Box Layout) lays elements out in a single row or a single column. You turn it on with display: flex on the parent element — the container — and all of its direct children become flex items.
justify-content distributes items along the main axis, while align-items aligns them along the cross axis. By default (flex-direction: row) the main axis is horizontal; choose column and the axes swap.
align-content distributes the lines of flex items and only works in a container that wraps — flex-wrap: wrap or wrap-reverse. With flex-wrap: nowrap (the default) all items sit on one line and align-content does not apply.
It is shorthand for flex-grow: 1, flex-shrink: 1 and flex-basis: 0%. Items with flex: 1 share the free space equally. In the playground you can set these values one by one and watch how they change the sizes.
Flexbox lays items out in one direction — a row or a column. CSS Grid controls rows and columns at the same time. Flexbox is handier for menus, button rows or centering; grid suits page layouts.
No. order only changes the visual order: the HTML order — and with it the reading order and Tab key order — stays the same. So put the order that matters in the markup itself.
Related tools
Flexbox: header menu and a row of cards
Flexbox practice exercise: put the logo and menu side by side in the header and line course cards up in an equal-height row that wraps on narrow screens.
Center an element horizontally and vertically
The simplest modern way to center a block using flexbox.
Hero section
A compact hero block with a heading, subtitle, and call-to-action button using flexbox.
Responsive CSS Grid cards
A card grid that adapts its column count to screen width, with no media queries.
Linking CSS
Lesson 11: three ways to add CSS — an external file via <link rel="stylesheet">, a <style> block in head and the style attribute. Example and task.
Build a card with CSS
Practice exercise: build a product card in HTML and link an external stylesheet to it.
CSS Formatter & Minifier
Format and compress CSS styles online. Local browser-only processing.
HTML Editor Online
Write HTML with syntax highlighting and line numbers, see a live preview, format or minify it, and open or save .html files — all in your browser.