font
Text
Sets several font values at once; anything omitted resets to its default.
| How to write it | font: 1rem/1.5 sans-serif; |
|---|---|
| Common values | 1rem/1.5 sans-serif |
| Inherited | Yes — children receive it |
| Sets all of | font-style, font-weight, font-size, line-height, font-family |
| Category | Text |
How to read this
- An inherited property only needs writing once on the parent — every child picks it up. Most text properties work this way.
- A shorthand resets whatever you leave out. Writing background: red alone also wipes a background image you set earlier.
- When rules collide, the more specific selector wins; only when specificity ties does source order decide.
- Animate transform and opacity for smoothness. Changing width or top forces the layout to be recalculated.
Frequently asked questions
Q. What is the CSS font property?
Sets several font values at once; anything omitted resets to its default.
Q. How do you write font?
As font: 1rem/1.5 sans-serif;
Q. Is font inherited?
Yes. Set it once on the parent and every child uses the same value without repeating it.
Q. What does the font shorthand set?
font-style, font-weight, font-size, line-height, font-family — and anything you leave out resets to its default.