Working with Text Properties

The text properties provide various text formatting options that allow you to format the text present in an HTML Web page. Using these properties, you can enhance the text added to a Web page (by changing the color of the text and decorating the text).

Below given lists the available text properties:

Property

Description

color

Specifies the foreground color of the text. You can set this property to either a predefined color name or a color value.

letter-spacing

Specifies the spacing between text characters. You can set this property to either normal or specify it in the form of the distance between two consecutive letters (in a word) using a unit identifier, such as pix (pixels), in (inches), pt (points, 1/72 of an inch), and cm (centimeters).

line-height

Specifies the distance between two lines. You can set this property to normal or specify it in the form of a length, number, or percentage value.

text-align

Specifies how the content of a block is aligned: left, right, center, or justified, in CSS2, you can also specify a string to align the text.

text-decoration

Specifies the decorations that are added to the text of an element, such as underlining, overlining, and line-through (that is strikethrough). You can set this property to none, underline, overline, line-through, or blink.

text-indent

Specifies the indentation of the first line of text in a block, you can specify this property in the form of either length or percentage.

text-shadow

Specifies a (comma separated) list of shadow effects that should be applied to text in the element. You can set this property to none, a predefined color name, a color value, or specify it in the form of a length value.

vertical-align

Specifies the vertical positioning of text in the element. You can set this property to baseline, sub, super, top, text-top, middle, bottom, text-bottom, or specify it in the form of a length value.

vertical-align

Specifies the vertical positioning of text in the element. You can set this property to baseline, sub, super, top, text-top, middle, bottom, text-bottom, to specify it in the form of a length or percentage value.

white-space

Specifies how white space inside an HTML element is handled. You can set this property normal, pre, or nowrap.

word-spacing

Specifies the space between two consecutive words in a line. You can either set this property to normal or specify it in the form of a length value.

In this section, you learn to how to work with text properties.

Let’s now learn how to work with some text properties, including color, text-indent, text-align, and text-decoration.