100–900
font-weight: 100 … 900100Learn CSS200Learn CSS300Learn CSS400Learn CSS500Learn CSS600Learn CSS700Learn CSS800Learn CSS900Learn CSSOne topic, visible examples, and the exact CSS to try. Open styles.css alongside this page. Resize the browser and hover or Tab through the controls.
Numeric weights run from 100 to 900. The font must include those weights for each step to look different. Arial commonly provides regular and bold, so some examples will look the same.
font-weight: 100 … 900100Learn CSS200Learn CSS300Learn CSS400Learn CSS500Learn CSS600Learn CSS700Learn CSS800Learn CSS900Learn CSSfont-weight: normal / boldNormal = 400
Bold = 700
The root font size is 16px. Each parent below has font-size:20px. Compare the references: rem uses the root; em and percentage font sizes use the parent.
font-size:16px16px text
font-size:1.5rem → 24px1.5rem text
font-size:1.5em → 30px1.5em text
font-size:150% → 30px150% text
font-size:12px / 20px / 32px12px text
20px text
32px text
Percentages depend on the property. These widths refer to the containing block. Viewport units refer to the browser viewport. A CSS pixel is not necessarily one physical screen pixel.
width:120px / 60% / 10remwidth:20vw; height:12vhDemo includes a minimum height and maximum width.
font-size:clamp(18px,3vw,36px)Flexible text
max-width:28chThis paragraph wraps within a width based on the font’s zero character, rather than an exact character count.
1vmin / 1vmax / 1dvhvmin: 1% of the smaller viewport dimension.
vmax: 1% of the larger dimension.
dvh: 1% of the dynamic viewport height.
These common display modes change layout behavior. They do not change the meaning of the HTML tag.
display:blockdisplay:inlinedisplay:inline-block; width:100px; height:55pxdisplay:flexdisplay:grid; grid-template-columns:repeat(2,1fr)display:none / visibility:hiddenThe hidden item below still occupies space:
display:inline-flex / inline-gridSet display:flex on the parent. Its direct children become flex items.
flex-direction:rowflex-direction:columnflex-wrap:wrap; items: flex-basis:100pxflex-wrap:nowrapflex-grow:1 / 1 / 2; flex-basis:0The third item receives twice the share of distributable space. Padding also contributes to visible width.
Distribute flex items along the main axis. These examples use a row, so the main axis runs horizontally.
justify-content:flex-startjustify-content:centerjustify-content:flex-endjustify-content:space-betweenjustify-content:space-aroundjustify-content:space-evenlyAlign-items controls the cross axis. In this row, it is vertical. Stretch affects items whose cross size is automatic.
align-items:flex-startalign-items:centeralign-items:flex-endalign-items:stretchalign-items:baselinegap:20pxfr shares remaining space in grid tracks after fixed sizes and gaps are accounted for. Content minimum sizes can affect track sizing.
grid-template-columns:repeat(3,1fr)grid-template-columns:1fr 2fr 1frgrid-template-columns:70px 1frrepeat(auto-fit,minmax(100px,1fr))Resize the page. The demo caps the minimum at the available width on very small screens.
Columns control horizontal tracks. Rows control vertical tracks. Numbered grid lines let an item span tracks.
grid-template-rows:45px 85pxfirst item: grid-column:1 / 3first item: grid-row:1 / 3grid-template-areas: "header header" "sidebar content" "footer footer"Gradients are background images generated by CSS. Change the direction, shape, position, and color stops.
linear-gradient(to right,#5edcff,#8c7dff)linear-gradient(135deg,#ffb764,#fa6095,#8c7dff)linear-gradient(to right,#5edcff 0% 50%,#8c7dff 50% 100%)radial-gradient(circle,#5edcff,#11243c)radial-gradient(circle at top left,#ffb764,#8c7dff,#11243c)conic-gradient(#5edcff,#8c7dff,#ffb764,#5edcff)Border shorthand combines width, style, and color. Different sides can also be styled separately.
border:3px solid #5edcffborder:3px dashed #5edcffborder:3px dotted #5edcffborder:6px double #5edcffborder-left:5px solid #b59affRadius rounds corners. 50% produces a circle when width and height are equal.
border-radius:8pxborder-radius:28pxborder-radius:999px100px × 100px; border-radius:50%border-radius:30px 0 30px 0Syntax: horizontal offset, vertical offset, blur, optional spread, then color. Inset draws inside the box. Shadows do not reserve layout space.
box-shadow:0 10px 24px #0007box-shadow:8px 8px 0 #b59affbox-shadow:0 0 22px #5edcff88box-shadow:inset 0 0 18px #000bThe illustration labels each layer. The outer colors visualize otherwise invisible spacing; inspect the real element in DevTools to see actual computed sizes.
content → padding → border → marginmargin:24px; padding:24px; border:8px solid #b59affPadding grows the space inside the background and border. Margin separates the element from its surrounding content.
padding:0padding:24pxmargin:0margin:24pxBoth boxes declare width:180px, padding:20px, and border:5px on each side. Margin is outside either measurement.
total width = 180 + 40 + 10 = 230pxtotal width = 180pxText-transform changes presentation without changing the source text.
text-transform:uppercaseLearn CSS With Nilesh
text-transform:lowercaseLearn CSS With Nilesh
text-transform:capitalizeLearn CSS With Nilesh
font-style:italicLearn CSS
text-decoration:underline / line-throughUnderline
Line through
letter-spacing:4pxLEARN CSS
text-align:leftAligned text
text-align:centerAligned text
text-align:rightAligned text
Unitless line-height multiplies the element’s font size. Compare the spacing between lines.
line-height:1.1CSS controls presentation.
Spacing affects readability.
Choose a comfortable height.
line-height:2CSS controls presentation.
Spacing affects readability.
Choose a comfortable height.
Hover the buttons to compare instant and smooth changes. Tab to see keyboard focus. CSS creates these effects without JavaScript.
no transitiontransition:background-color .3s ease, transform .3s ease, box-shadow .3s easetransform:translateX(20px)transform:rotate(12deg)transform:scale(1.15)Move the pointer over each sample. The cursor communicates a hint; it does not implement dragging, clicking, or a disabled state.
cursor:autocursor:defaultcursor:pointercursor:textcursor:movecursor:helpcursor:not-allowedcursor:crosshaircursor:grab