CSS Reference Sheet – Cards

Practice: Build CSS Cards →

This page shows the CSS tools you use to build cards and simple webpages. You do not need to memorize everything. Use it while building.


CSS Level 1 — Essential Properties (Already Known)

These are the 11 essential CSS properties. If you can build cards using only these, your foundation is strong.

PropertyExampleWhat it does
colorcolor: white;Text color
background-colorbackground-color: black;Background color
widthwidth: 200px;Element width
heightheight: 50px;Element height
border-colorborder-color: red;Border color
border-widthborder-width: 3px;Border thickness
border-styleborder-style: solid;Makes border visible
border-radiusborder-radius: 8px;Rounded corners
font-sizefont-size: 18px;Text size
font-weightfont-weight: bold;Text thickness
font-familyfont-family: Arial;Font style

CSS Level 2 — Card & Page Tools

ConceptExampleWhat it does
div<div>A box
span<span>Inline text
class.card {}Styles many
id#main {}Styles one
paddingpadding: 15px;Space inside
marginmargin: 20px;Space outside
text-aligntext-align: center;Align text
width: 100%width: 100%;Fill parent
borderborder: 2px solid black;Border shorthand
linear-gradient background: linear-gradient(to bottom, navy, crimson, orange); Blends multiple colors smoothly
box-shadow box-shadow: 0 8px 18px rgba(0,0,0,0.25); Adds depth under a card
aspect-ratioaspect-ratio: 3 / 4;Card shape

Special Topic — display

The display property decides how a box behaves.

ValueMeaning
blockBig box, own line (default for div)
inlineActs like text (no width or height)
inline-blockBox that sits in a row (best for cards)

display: block (default)

Card
Card
Card

Each card is on its own line.

display: inline (⚠ do NOT use for cards)

Card
Card
Card

Inline elements act like text.
They ignore width and height, so cards break.

display: inline-block (✅ best for cards)

Card
Card
Card

Cards stay boxes and sit in a row.


Expanded Explanations

Colors (rgb, rgba, hex)

color: #1F214D;

background-color: rgb(30, 30, 60);

box-shadow: 0 8px 18px rgba(0,0,0,0.18);

rgb() uses numbers from 0–255.
rgba() adds transparency (alpha).
Hex is a short color code starting with #.

1. Gradients

background: linear-gradient(to bottom, #1F214D, #BF3475, #FFCE61);

Gradients blend colors smoothly. 2–3 colors is usually enough.

2. Padding and Margin (Spacing)

Padding = space inside the box (content moves inward)
Margin = space outside the box (the box moves away from other things)

/* ONE number – all sides */
padding: 10px;

Adds 10px of space on all four sides inside the box. The content moves inward evenly.


/* TWO numbers – vertical, horizontal */
padding: 10px 20px;

10px on top and bottom
20px on left and right
This is very common for buttons and cards.


/* FOUR numbers – top, right, bottom, left */
padding: 10px 0 30px 20px;

This follows the clock rule:
Top = 10px
Right = 0px
Bottom = 30px
Left = 20px


margin: 20px;

Adds 20px of space outside the box on all sides. The box moves away from other elements.


margin: 10px 30px;

10px top and bottom
30px left and right
Useful when spacing cards horizontally.


margin: 10px 0 30px 20px;

Top = 10px
Right = 0px
Bottom = 30px
Left = 20px


margin: auto;

Tells the browser to automatically center the box horizontally.
Works only when the element has a width.

Memory tip:
4 numbers always go like a clock:
top → right → bottom → left
(12 → 3 → 6 → 9)

Order is like a clock: top → right → bottom → left

3. Box Shadow (Depth)

A shadow makes a card feel lifted off the page.

Shadow part 1: Left / Right

box-shadow: 7px 0 0 black;
Shadow →

7px moves the shadow to the right.
Negative numbers move it left.

Shadow part 2: Up / Down

box-shadow: 0 7px 0 black;
Shadow ↓

7px moves the shadow downward.
Negative numbers move it upward.

Shadow part 3: Blur and Transparency (Real shadows)

box-shadow: 0 8px 18px rgba(0,0,0,0.25);
Soft shadow

Explanation of each part:

Why use rgba for shadows?
Real shadows are not solid black.
Transparency makes them look soft and natural.

Good rule of thumb:
Small X, medium Y, soft blur, transparent black.

4. Aspect Ratio

aspect-ratio: 3 / 4;

Set width OR height — not both. The browser keeps the shape.


You are not expected to remember everything. This page is your toolbox.