控制文本的对齐方式

你可以使用text-align属性的三个值left、center和right来对齐文本。更好的是,在Netscape Navigator 4.0和Internet Explorer 4.0中,你可以建立完全调整过的文本。表7.5使用了text-align属性的所有四个值(见图7.28):

表7.5 对齐方式举例

<HTML>

<HEAD>
<TITLE> Style </TITLE>

<STYLE>

<!--

.Left {text-align: left}

.Right {text-align: right}

.Center {text-align: center}

.Justify {text-align: justify}

-->

</STYLE>

</HEAD>

<BODY>

<P CLASS=Left>

This text is left aligned. See how the edges of this paragraph line up.

This text is left aligned. See how the edges of this paragraph line up.

This text is left aligned. See how the edges of this paragraph line up.

This text is left aligned. See how the edges of this paragraph line up.

This text is left aligned. See how the edges of this paragraph line up.

This text is left aligned. See how the edges of this paragraph line up.

</P>

<P CLASS=Right>

This text is right aligned. See how the edges of this paragraph line up.

This text is right aligned. See how the edges of this paragraph line up.

This text is right aligned. See how the edges of this paragraph line up.

This text is right aligned. See how the edges of this paragraph line up.

This text is right aligned. See how the edges of this paragraph line up.

This text is right aligned. See how the edges of this paragraph line up.

</P>

<P CLASS=Center>

This text is centered. I float in the middle of the screen.

This text is centered. I float in the middle of the screen.

This text is centered. I float in the middle of the screen.

This text is centered. I float in the middle of the screen.

This text is centered. I float in the middle of the screen.

This text is centered. I float in the middle of the screen.

</P>

<P CLASS=Justify>

This text is justified. See how the edges of this paragraph line up.

This text is justified. See how the edges of this paragraph line up.

This text is justified. See how the edges of this paragraph line up.

This text is justified. See how the edges of this paragraph line up.

This text is justified. See how the edges of this paragraph line up.

This text is justified. See how the edges of this paragraph line up.

</P>

</BODY>

</HTML>

图7.28 使用style sheet来对齐文本