Horizontal alignment of text is controlled using STYLE="text-align: ", which is a style that can be used on all types of text section, including the BODY tag on the page. Relative to the right and left margin, you have the following options for alignment:
Value | Effect |
left | Alignment to the left margin. |
right | Alignment to the right margin. |
justify | Alignment to both margins. |
center | Centrered text |
This is a few lines from Kenneth Grahame's
The Wind in the Willows in a DIV tag for demonstration:
Using STYLE="text-align:left"
'Hullo, Mole!' said the Water Rat.
'Hullo, Rat!' said the Mole.
'Would you like to come over?' enquired the Rat presently.
'Oh, its all very well to TALK,' said the Mole, rather pettishly, he being new to a river and riverside life and its ways.
The Rat said nothing, but stooped and unfastened a rope and hauled on it; then lightly stepped into a little boat which the Mole had not observed. It was painted blue outside and white within, and was just the size for two animals; and the Mole's whole heart went out to it at once, even though he did not yet fully understand its uses.
Using STYLE="text-align:right"
'Hullo, Mole!' said the Water Rat.
'Hullo, Rat!' said the Mole.
'Would you like to come over?' enquired the Rat presently.
'Oh, its all very well to TALK,' said the Mole, rather pettishly, he being new to a river and riverside life and its ways.
The Rat said nothing, but stooped and unfastened a rope and hauled on it; then lightly stepped into a little boat which the Mole had not observed. It was painted blue outside and white within, and was just the size for two animals; and the Mole's whole heart went out to it at once, even though he did not yet fully understand its uses.
Using STYLE="text-align:justify"
'Hullo, Mole!' said the Water Rat.
'Hullo, Rat!' said the Mole.
'Would you like to come over?' enquired the Rat presently.
'Oh, its all very well to TALK,' said the Mole, rather pettishly, he being new to a river and riverside life and its ways.
The Rat said nothing, but stooped and unfastened a rope and hauled on it; then lightly stepped into a little boat which the Mole had not observed. It was painted blue outside and white within, and was just the size for two animals; and the Mole's whole heart went out to it at once, even though he did not yet fully understand its uses.
Using STYLE="text-align:center"
'Hullo, Mole!' said the Water Rat.
'Hullo, Rat!' said the Mole.
'Would you like to come over?' enquired the Rat presently.
'Oh, its all very well to TALK,' said the Mole, rather pettishly, he being new to a river and riverside life and its ways.
The Rat said nothing, but stooped and unfastened a rope and hauled on it; then lightly stepped into a little boat which the Mole had not observed. It was painted blue outside and white within, and was just the size for two animals; and the Mole's whole heart went out to it at once, even though he did not yet fully understand its uses.
Vertical alignment of text is controlled using STYLE="vertical-align: ", which is a style that can be used on all types of text section, including the BODY tag on the page. The vertical alignment is normally only used in text fields standing side by side, where the texts have different lengths, e.g. in tables. In regards to text, you have the following options:
Value | Effect |
top | The text is placed at the top of the text field. |
middle | The text is placed in the middle of the text field. |
bottom | The text is placed at the bottom of the text field. |
This is a table where the cell, the TD tag, is vertically aligned using STYLE="vertical-align: ", for demonstration:
Using STYLE="vertical-align:top" |
Using STYLE="vertical-align:middle" |
Using STYLE="vertical-align:bottom" |