Text in CSS: Other attributes

Besides the font, the CSS language allows you to make a few other changes in your text:


Self-explanatory, color lets you set the colour of the font in which you are working. It accepts names, rgb and hexadecimal values.

color: red;
color: rgb(104,36,108);
color: #ffdead;


This lets you specify whether you are writing from left to right or from right to left. It's useful for some Asian languages.

direction: ltr;
direction: rtl;

Letter Spacing and Word Spacing

Self-explanatory again, they let you specify these characteristics. Use measures to complete them.

letter-spacing: 105%;
word-spacing: 107%;


You said you wanted your text centred or justified? Here is how:

text-align: center;
text-align: left;
text-align: right;
text-align: justify;

Text indent

This will indent the first line of every paragraph. Tip: use percentages with this one:

text-indent: 5%;

Text transform and decoration

Self-explanatory again. Look at the examples. Extra tip: avoid using blink.

text-transform: capitalize;
text-transform: small-caps;
text-transform: uppercase;
text-decoration: none;
text-decoration: underline;
text-decoration: overline;
text-decoration: line-through;
text-decoration: blink;

Knowledge + Computers