CSS - Text formatting

  »   CSS  »   CSS Tutorial - Text formatting

Text color can be expressed same as the background color. You can use both hexadecimal or RGB systems or use name the color in English. Take a look at this color chart for more details

CSSbody { color: #efefef; }
h1 { color: red; }
p { color: rgb(255,0,0); }

When you set the color for the body tag, you are telling the browser that he has to use that specific color as the default text color.

Text alignment

CSSh1.my_class { text-align: center; }
.my_class { text-align: center; }

You can align text just like you always do: left, right, center, or justified-

CSS - Text decoration and transforming

Text decoration it's normally used to set or unset some default tag properties. The browser will underline all links by default, for example. You can change this behavior by setting the text-decoration to none:

CSSa { text-decoration: none; }

Here are some other values for the text-decoration property:

CSSh1 { text-decoration: overline; }
h2 { text-decoration: line-through; }
h3 { text-decoration: underline; }
h4 { text-decoration: blink; }

CSS can also make text to be uppercase, lowercase, or just capitalize the first letter of every word.

CSSp { text-transform: uppercase; }
p { text-transform: lowercase; }
p { text-transform: capitalize; }

And last we also have the text-indent property that is used to indent the first line of a paragraph

CSSp { text-indent: 30px; }