Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

text-align

The text-align property lets you to set the horizontal alignment of tags. This is similar to the align property on paragraphs, headings or divisions. For example:

h1 {text-align: left;}
h1 {text-align: center;}
h1 {text-align: right;}

The possible values are: left, right, center, justify and they work in the same way as in a Desk Top Publishing package. You can only use justify for Internet Explorer 4 or 5.

This property works on block tags such as <p>, <hn>, <blockquote> and <ul>.

If you choose to justify text and the browser doesn’t support it, text will usually justify left for western languages. Justify may work differently for languages that read right-to-left.

In CSS2, you can also set the value to a string. This only applies to tables. If you set the text-align property to a string for other tags, the browser simply aligns to the left (or to the right for right-to-left languages).

Here’s an example:

td {text-align: ".";}

In this example, text in table cells aligns on a decimal point.