HTML Text Alignment
You can set the alignment of any HTML element using the
For example, suppose we want to center a paragraph. First, we'll create a styles class called
<STYLE TYPE="text/css">
<!--
.centeralign {text-align:center}
-->
</STYLE>
Now we can set any paragraph to
<P CLASS="centeralign"> get Centered </P> which gives us get Centered We can apply the same class to a
<DIV CLASS="centeralign"> This is a center aligned bunch of text <P> It stays center aligned because it is within a DIV which has a center aligned style. <P> Each element within the center aligned DIV inherits the center aligned style. </DIV> which gives us This is a center aligned bunch of text It stays center aligned because it is within a DIV which has a center aligned style. Each element within the center aligned DIV inherits the center aligned style.
If we want to center everyting on the page, the easiest thing to do is to apply the style rull to the
<STYLE TYPE="text/css">
<!--
BODY {text-align:center}
-->
</STYLE>
which is used in this page.
The same concepts can be applies to
<STYLE TYPE="text/css">
<!--
.rightalign {text-align:right}
-->
</STYLE>
and then applying the class to a paragraph:
<P CLASS="rightalign"> get Right. </P> which gives us get Right. |