HTML and CSS Reference
In-Depth Information
center Center text, leaving ragged ends on both sides.
justify Align text on both sides.
CSS3 adds a new property called text-align-last , which controls the alignment of the last line in a block of
text. It accepts the same values as text-align .
Internet Explorer has supported text-align-last since IE 5. In Firefox 12+, it's supported with the browser-
specific prefix as -moz-text-align-last . The style rule for the paragraph in text-align-last.html contains the
following declarations:
p {
text-align: justify;
-moz-text-align-last: right;
text-align-last: right;
Figure 4-8 shows the result in IE 9. The first two lines of text are justified, and the final line is aligned right. In
other browsers apart from Firefox 12+, the final line is aligned left.
Figure 4-8. Internet Explorer was the first browser to support text-align-last
Aligning Text Vertically
Vertical alignment is controlled by the vertical-align property—perhaps one of the least well understood
CSS properties. Many newcomers to CSS mistakenly believe it can alter the vertical position of block elements,
such as paragraphs. It can't . he vertical-align property applies to inline elements, such as images and
<span> elements, and moves them in relation to the surrounding text. The HTML <sub> and <super> elements
automatically shift text vertically in relation to the rest of the line. As a result, vertical-align is not as useful for
text as you might expect.
The property accepts the following values:
baseline Align the text to the same baseline as text in the parent element. This is the
default value.
middle Align the vertical midpoint 0.25em above the baseline of the parent.
sub Align text to the proper position for a subscript. This does not alter the size of the
super Align text to the proper position for a superscript. This does not alter the size of
the font.
text-top Align the top of the imaginary text box with the top of the text in the parent
Search WWH ::

Custom Search