Here’s what text control properties can handle:
| Name | Property |
|---|---|
| Font Size | font-size |
| Font Weight | font-weight |
| Font Style | font-style |
| Line Height | line-height |
| Font Family | font-family |
| Font Shorthand | font |
| Text Indent | text-indent |
| Text Align | text-align |
| Text Decoration | text-decoration |
| Color | color |
Font Size
The value is the text size, usually in px.
| |
Font Weight
The value can be a number or a keyword.
| |
Font Style
Usually used to remove default italic effects on text.
| |
Line Height
Sets spacing for multi-line text. There are two types of values:
| |
Line height means text height + top spacing + bottom spacing.
When the line-height property’s value equals the box (div) height property’s value, you can vertically center content.
| |
Font Family
Controls the font face for text. The value is the font name.
| |
Typically, you’ll set multiple fonts.
| |
The execution order is left to right. The browser checks if the system has the current font; if not, it checks for the next one, until the last. The last one above is a sans-serif font family name.
font Shorthand Property
When setting fonts during development, you might do this:
| |
This can be simplified to:
| |
This property is usually used for setting common text styles on a webpage. Values must be written in order. font-size and font-family are required; others can be omitted.
Text Indent
There are two types of values: px or em. em refers to the current tag’s font size.
| |
Text Align
The text-align property has three values: left, center, right.
| |
This property isn’t just for text alignment. For example, you can use it to center an image like this:
| |
Essentially, text-align controls content alignment. The property should be set on the content’s parent. In the example above, the <img>’s parent is the div.
Text Decoration
| Effect | Value |
|---|---|
| None | none |
| Underline | underline |
| Line-through | line-through |
| Overline | overline |
| |
Text Color
| Color Representation | Value | Description |
|---|---|---|
| Keywords | English words | red, green, aqua, etc. |
| RGB Notation | rgb(r, g, b) | r, g, b represent red, green, blue primary colors, values 0-255 |
| RGBA Notation | rgba(r, g, b, a) | a represents transparency (alpha), values 0-1 |
| Hexadecimal Notation | #RRGGBB | Pairs of two. Can be shortened if pairs are identical. #ffcc00 -> #fc0 |
| |