Home >Web Front-end >Front-end Q&A >What does text-align mean in css?
text-align means "horizontal alignment" in Chinese and is an attribute in CSS used to specify the horizontal alignment of element text; the syntax format is "text-align: value;", the value can be left (left Alignment), right (right alignment), center (center alignment), justify (justify both ends).
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
text-align is a built-in property in CSS that is used to specify the horizontal alignment of element text.
Attribute values that can be set:
Value | Description |
---|---|
left | Arrange text to the left. Default: determined by the browser. |
right | Arrange text to the right. |
center | Arrange the text to the center. |
justify | Achieve the effect of aligning text on both ends. |
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> h1 { text-align: center; } p.date { text-align: right; } p.main { text-align: justify; } </style> </head> <body> <h1>CSS text-align 实例</h1> <p class="date">2015 年 3 月 14 号</p> <p class="main">“当我年轻的时候,我梦想改变这个世界;当我成熟以后,我发现我不能够改变这个世界,我将目光缩短了些,决定只改变我的国家;当我进入暮年以后,我发现我不能够改变我们的国家,我的最后愿望仅仅是改变一下我的家庭,但是,这也不可能。当我现在躺在床上,行将就木时,我突然意识到:如果一开始我仅仅去改变我自己,然后,我可能改变我的家庭;在家人的帮助和鼓励下,我可能为国家做一些事情;然后,谁知道呢?我甚至可能改变这个世界。”</p> </body> </html>
Rendering:
(Learn Video sharing: css video tutorial)
The above is the detailed content of What does text-align mean in css?. For more information, please follow other related articles on the PHP Chinese website!