The font-size property sets how large text is drawn. Changing it also updates font-relative lengths such as em and ex on that element.
You can use absolute keywords (medium, large), relative keywords (larger, smaller), lengths (1rem, 16px), or percentages. The property is inherited. Pair it with font-family and line-height for readable type.
Baseline · Widely available.
Not deprecated and not experimental. Prefer relative sizes such as rem when you want text to respect user font preferences.
Read the parent. Each 1.5em is 1.5 × that span’s parent font size.
Nest and multiply. The inner span is 1.5 × the middle span, so it grows again.
Compare with rem. The same nesting with rem would keep every span the same size.
When to use em. Useful when a piece of text should scale with its local container, not the whole page.
Edge Cases & Pitfalls
If text looks too big, too small, or inconsistent, check these first.
em
em compounds in nested elements
A nested 1.5em inside another 1.5em becomes much larger than you might expect. Prefer rem when you want stable sizing.
px
Fixed px can hurt accessibility
Some browsers do not let users rescale text set only in pixels. Prefer relative units for body copy when inclusive design matters.
%
Percentages use the parent size
font-size: 150% means 1.5 × the parent’s font size, not 150% of the viewport.
shorthand
font can reset size
The font shorthand sets size and can overwrite a earlier font-size rule. Put size after the shorthand, or include it in the shorthand.
zero
Negative sizes are invalid
Length and percentage values must be zero or positive. A negative font-size is ignored.
Compatibility
Browser Support
font-size is a browser CSS property for text sizing. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
font-size
Supported in all modern browsers and Internet Explorer. Core keyword, length, and percentage values are universal.
100%Modern browser support
Google ChromeAll
Full support
Mozilla FirefoxAll
Full support
Apple SafariAll
Full support
Microsoft EdgeAll
Full support
OperaAll
Full support
Samsung InternetAll
Full support
Internet ExplorerAll
Full support
font-sizeWidely supported
Bottom line: Safe to use everywhere. Prefer rem or other relative sizes for accessible body text. It is not a runtime API.
Remember
Key Takeaways
Role: set the size of text (and related em/ex units).
Prefer rem: predictable scaling from the root without nesting surprises.
em / %: relative to the parent and can compound when nested.
Initial value:medium. Inherited by default.
One line:font-size: 1.25rem; sizes text from the root in a way that stays easy to scale.
Frequently Asked Questions
It sets the size of text for an element. Changing it also updates font-relative units such as em and ex on that element.
The initial value is medium. Browsers usually treat medium body text as about 16px when the user has not changed preferences.
Prefer rem (or other relative sizes) for most text so size can scale with the root and user settings. Use px when you need a fixed pixel size for a small UI detail.
em is relative to the parent’s font size and can compound inside nested elements. rem is relative to the root html font size, so nesting does not multiply the size.
Yes. Children inherit the computed size unless they set their own font-size.
It is Baseline Widely available and works in all modern browsers and Internet Explorer. It is a browser CSS property, not a Node.js feature.