text-align

The text-align property specifies how inline content of a block is aligned.

Syntax

text-align: left | right | center | justify | inherit
Initial: left if direction is ltr, right if direction is rtl
Applies To: block-level elements, table cells, and inline blocks
Inherited: yes
Percentages: NA
Media: visual

Values

text-align: value
Value Description
center Center text
justify Justify text
left Left-align text
right Right-align text

DOM

[window.]document.getElementById("element-id").style.textAlign = "text-align";

Example | center

Example | justify

Example | left

Example | right

Example | DOM

External

W3C Cascading Style Sheets, level 1

W3C Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification