Set the Text Alignment
By Stephen Bucaro
Use the text-align property to set the text alignment. You can define the
text to be aligned center, left, right, or justify.
<p style="text-align:left;">Text aligned left</p>
Text aligned left
<p style="text-align:right;">Text aligned right</p>
Text aligned right
<p style="text-align:center;">Text centered</p>
Text centered
text-align:justify causes small amounts of spacing to be added between words
so that all the lines line up against the left and right margins and have equal width.
Normal paragraph shown below:
As Little Red Riding Hood was going through the woods, she met with a wolf,
who had a very great mind to eat her up, but he dared not, because of some
woodcutters working nearby in the forest.
text-align:justify paragraph shown below:
As Little Red Riding Hood was going through the woods,
she met with a wolf, who had a very great mind to eat her up, but he dared not,
because of some woodcutters working nearby in the forest.
the text-align property gives you limited control of text position, if you
want more exact control, use the margin-left or margin-right property.
The example below aligns the text 100 pixels from the left.
<p style="margin-left:100px;">Text 100 pixels from left</p>
Text 100 pixels from left
More CSS Quick Reference: • Set the border-collapse • Use word-wrap Property to allow Line Breaks in the Middle of Words • Set the Background Color • Set The Cursor Style • Set the Font Size • Set List Bullets Position • CSS Units of Measurement • Grouped Selectors • Set the box-sizing Property • Descendant Selector
|