Master the Art of Beautiful Web Design
CSS selectors target HTML elements for styling. Understanding specificity helps predict which styles win.
Inline styles (1000) > ID selectors (100) > Classes/Attributes (10) > Elements (1)
Every HTML element is a box with: margin, border, padding, and content.
Always use box-sizing: border-box to include padding/border in the element's width. No more overflow issues!
Flexbox is perfect for row or column layouts. It's your go-to for aligning items and creating responsive designs.
| Property | Values | Purpose |
|---|---|---|
display: flex |
flex, inline-flex | Enables flexbox |
flex-direction |
row, column, row-reverse, column-reverse | Main axis direction |
justify-content |
flex-start, center, space-between, space-around | Align along main axis |
align-items |
stretch, flex-start, center, baseline | Align along cross axis |
flex-wrap |
nowrap, wrap, wrap-reverse | Allow items to wrap |
gap |
10px, 1rem, 5% | Space between items |
flex-grow - How much item grows (default 0)
flex-shrink - How much item shrinks (default 1)
flex-basis - Initial size before growing/shrinking
CSS Grid is perfect for complex, two-dimensional layouts (rows AND columns).
| Property | Values | Purpose |
|---|---|---|
display: grid |
grid, inline-grid | Enables CSS Grid |
grid-template-columns |
1fr 1fr 1fr, repeat(3, 1fr) | Define column sizes |
grid-template-rows |
auto, 100px, 1fr | Define row sizes |
gap |
20px, 1rem | Space between rows/columns |
grid-template-areas |
"header header", "sidebar main" | Name grid areas |
Flexbox: Navigation bars, card layouts, centering elements, one-dimensional layouts
Grid: Page layouts, dashboards, magazine-style grids, complex two-dimensional layouts
Make your website look great on all devices - phones, tablets, and desktops.
Always include this in your HTML <head>:
Define reusable values throughout your CSS. Change them once, update everywhere!
Add movement and interactivity to make your websites feel alive.
Smoothly change properties over a duration.
Create complex multi-step animations.
animation-name - Name of @keyframes
animation-duration - How long (1s, 500ms)
animation-timing-function - ease, linear, ease-in-out
animation-iteration-count - number or infinite
Requirements: