CSS - text-align 属性



text-align 属性确定文本相对于页面边距的对齐方式。

可能的值

  • left:左对齐。

  • right:右对齐。

  • justify:两端对齐。

  • center:居中对齐。

应用于

所有块级元素。

Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.

DOM 语法

object.style.textAlign = "justify";

CSS text-align - 基本示例

这是一个示例

Open Compiler
<html> <head> </head> <body> <h2>Text Alignment</h2> <p style="text-align: left;">Text Left Alignment.</p> <p style="text-align: right;">Text Right Alignment.</p> <p style="text-align: center;">Text Center Alignment.</p> <p style="text-align: justify; border: 2px solid red; width: 200px; height: 100px;"> Text Justify Alignment. This alignment aligns the text based on both the margins, left and right. </p> </body> </html>
广告