Formatting Text

Text Color

color property sets the color of the text.

Property Possible Values Description
color color name Example: red
Hexadecimal value Example: #F00
RGB value Example: rgb(255,0,0)

Syntax for using color property:

<p style="color:#F00";>

Text Align

text-align property is used to set the horizontal text alignment.

Property Possible Values Description
text-align left aligns the text to the left
right aligns the text to the right
center aligns the text to the center
justify aligns the text to fill the whole assigned text area
inherit inherit the value of element's parent

Syntax for using text-align property:

<p style="text-align:center;>

Text Indentation

text-indent property is used to indent the first line of a text.

Property Possible Values Description
text-indent length (pixel or em) Example: 50px
percentage Example: 10%
inherit inherit the value of element's parent

Syntax for using text-indent property:

<p style="text-indent:10px;>

Text Decoration

text-decoration property is used to add or remove the decoration from the text.

Property Possible Values Description
text-decoration none no text decoration
underline text is having a line below it
overline text is having a line above it
line-through text is having a line in the middle of it
blink blinking text
inherit inherit the value of element's parent

Syntax for using text-decoration property:

<p style="text-decoration:none;>

Text Transformation

text-transform property is used to control captalization effect of a text.

Property Possible Values Description
text-transform none no effect
capitalize capitalize first character of each word in a text
uppercase all characters in uppercase
lowercase all characters in lowercase
inherit inherit the value of element's parent

Syntax for using text-transform property:

<p style="text-transform:uppercase;>

Line Height

line-height property sets vertical distance between baselines of two lines. Negative value is not accepted for line-height.

Property Possible Values Description
line-height normal default value
number line-height is number multiplied by font-size
length specified fixed length defined in px or em
percentage line height is percentage multiplied by font-size
inherit inherit the value of element's parent

Syntax for using line-height property:

<p style="line-height:200%;">

Letter Spacing

letter-spacing property defines the spacing between text characters.

Property Possible Values Description
letter-spacing normal default value
length fixed length in px or em
inherit inherit the value of element's parent

Syntax for using letter-spacing property:

<p style="letter-spacing:2px;">

Vertical Align

vertical-align is used to specify vertical alignment of a text.

Propery Possible Values Description
vertical-align baseline baseline of the element is aligned with the baseline of its parent
sub subscript the element
super superscript the element
top aligns the top of the element with the top of the whole line
text-top aligns the top of the element with the top of its parent
middle aligns the middle of the element with the baseline of its parent
bottom aligns the bottom of the element with the bottom of the whole line
text-bottom aligns the bottm of the element with the bottom of its parent
percentage raises or lowers the element by this value of line-height
length raises or lowers the element by this value
inherit inherit the value of element's parent

Syntax for using vertical-align property:

<p style="vertical-align:middle;">

Word Spacing

word-spacing property defines the spacing between words in a text line.

Property Possible Values Description
word-spacing normal default value
length fixed value in pixels or em.
inherit inherit the value of element's parent

Syntax for using word-spacing property:

<p style="word-spacing:5px;">

direction

direction property specifies the direction of the text.

Property Possible Values Description
direction ltr left to right text direction
rtl right to left text direction
inherit inherit the value of element's parent

Syntax for using direction:

<p style="direction:rtl;">
<< CSS Core Concepts Fonts >>