fontA shorthand property:
font-stylefont-weightfont-variantfont-sizeline-heightfont-familyfont-sizeValues: any number with a unit
15px200%1.2em1.5rem14vwline-heightValues: any number, including unitless
1.620px200%1.2em1.5rem18vwfont-styleValues: keywords
normalitalicobliqueoblique 15degfont-weightValues: keywords, numbers
normalbold, boldest, boldestlight, lightest, lightest100 - 900font-familyValues: comma-separate list of font-names
sans-serifGeorgia, serifLobster, fantasy-apple-system, sans-seriffont-familyBut where do custom fonts come from?
📌
font-variantEnables OpenType features
Values: keywords… lots of keywords
Also a shorthand
font-variantEnables OpenType features
Values: keywords… lots of keywords
Also a shorthand
font-feature-settingsEnables OpenType features
Values: keywords… lots of keywords
text-decorationline, style, color
text-transformcapitalize, uppercase, lowercase, full-width
text-alignleft, right, start, end, center, justify, etc
text-shadowValue: x-offset, y-offset, blur-radius, color
text-indentValue: any number with a unit
letter-spacingValue: any number with a unit (except %)
word-spacingValue: any number with a unit (except %)
white-spacenowrap, pre, pre-wrap, pre-line
text-overflowclip, ellipsis, [string]*
* poor support
hyphensoverflow-wrapword-breakVarious price points & subscriptions
Add a stylesheet link or JS script tag to your site
Managed in your asset pipeline & served from your domain (or CDN)
@font-face {
font-family: "My Cool Font";
src: url("path/to/file.woff") format("woff");
font-weight: 400;
font-style: normal;
}
.cool-font {
font-family: My Cool Font, sans-serif;
}
Screen-width is unpredictable.
Orientation is unpredictable.
Fallback fonts are unpredictable.
User zoom is unpredictable.
Readable font-size: avoid pixels
Readable line-length: 45-75 characters
Readable line-height: proportional to line-length
Pick a reasonable scale & multiply
Narrower screens? Smaller modular scale.
Wider screens? Larger modular scale.
Consistent vertical spacing between elements
Bonus: every element’s line-height matches the rhythm
Double bonus: shift every element to baseline alignment
Have inline images? You’ll never have vertical rhythm.
¯\_(ツ)_/¯
More important things should be more visually interesting.
Don’t add more visual variety if an element is already distinct.
Think of all users; don’t rely on weak differences (e.g., color only).
p {
font: 1em/1.4;
color: #333;
}
h2 {
font: 1.44em/1 bold;
color: #112;
/* Probably don't add all this: */
font-style: italic;
font-variant: small-caps;
text-decoration: underline dashed orange;
}
Caution! Don’t rely on client-side JS to handle typography in real life!
jdsteinbach