2 CSS Text Styling Cheatsheet
2 CSS Text Styling Cheatsheet
This is cheatsheet focuses on the CSS properties and values you can use to style your text.
1 HTML tag { 1 p {
6 } 6 }
TEXT STYLES
color
Sets the font color. Accepts either the color name or the hex value of the color.
1 color: purple;
2 color:#800080;
font-family
Sets the font for the text. Will accept any web safe font (which is about 20, depending on the
browser) - we will cover all the web safe fonts in the next step. Can be a prioritized list of fonts; if
the first font listed is not available in the browser, it will default to the second, and so on. You can
also write s
ans-serif or serif and the font will default to the browser’s sans serif or serif font.
text-align
Sets the alignment of the text – left (default), r
ight, c
enter, or justify – the same options
you have in Word.
1 text-align:center;
font-style
For if you want to italicize your text CSS instead of <em> HTML tags. Font-style takes the
values normal (default), italic, and oblique.
1 font-style:italic;
font-weight
Style your text b
old without the <strong> HTML tags; takes the values normal, bold, bolder,
lighter, or a number from 100 to 900.
1 font-weight:bold;
text-transform
Allows you to make all your text uppercase or lowercase; takes the values capitalize,
uppercase, and lowercase.
1 text-transform:uppercase;
font-variant
This is a fun one - you can actually make your text small caps by giving this attribute the
descriptor: s
mall-caps.
1 font-variant: small-caps;
text-decoration
Underline, o
verline, line-through, none. This can be used to remove the default underline
on elements.
1 text-decoration:none;
line-height
The default is for the line-height to be equivalent to the font-size. If you want to make it smaller or
bigger, you set it with the line-height property. Accepts pixels, em, numbers, and percentages.
1 line-height:150%;
text-indent
Sets the width of the tab indent - takes pixels, ems, or percentages
1 text-indent: 3em;