Text

Typography is an incredibly powerful design feature and, in reality, styling text with CSS is actually simple.

Let's see how.

color

The color CSS property defines the color of the text and looks like this:

color: red;

Alternatively, it can look like this:

color: #f00;

Description

The color property supports all color modes, HEX, RGB, RGBa, HSL, HSLs, and color name.

CSS:

/*Color Name*/
.element { color: red; }
/*HEX*/
.element { color: #f00; }
/*RGB*/
.element { color: rgb(255, 0, 0); }
/*RGBa - Color has 50% opacity*/
.element { color: rgba(255, 0, 0, .5); }
/*HSL*/
.element { color: hsl(0, 100%, 50%); }
/*HSLa - Color has 50% opacity*/
.element { color: hsla(0, 100%, 50%, .5); }

text-align

The text-align CSS property defines the alignment of the text, ...

Get Web Developer's Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.