Learn how to style text and fonts using CSS to create beautiful and readable typography
Typography is a fundamental aspect of web design
font-family
property specifies the typeface that will be used for text. You can provide multiple font names as a “fallback” system, so if the browser doesn’t support the first font, it can use the next one.
@font-face
to define custom fonts:
font-size
property sets the size of the text. There are several units you can use:
rem
or em
. The rem
unit is particularly useful as it’s always relative to the root element, avoiding compounding issues that can occur with em
.font-weight
property sets the thickness or boldness of the font:
font-style
property is mainly used to specify italic text:
font-variant
property can be used to display text in small-caps:
font
shorthand property sets all font properties in one declaration:
text-align
property sets the horizontal alignment of text:
text-decoration
property adds decorative lines to text:
text-transform
property controls text capitalization:
text-indent
property specifies the indentation of the first line in a text block:
letter-spacing
property adjusts the space between characters:
word-spacing
property adjusts the space between words:
line-height
property sets the height of a line of text, affecting the space between lines:
text-shadow
property adds shadow effects to text:
white-space
property specifies how white space inside an element is handled: