Multiple properties in CSS control the formatting of text. Several properties allow you to align text horizontally and vertically—aligning with other pieces of text or other elements around them.
Controlling horizontal alignment
You can use the text-align property to align blocks of text in four basic ways: left, right, center, or full. The following code and the output show the effect of the justification settings:
The four basic types of text justification.
Controlling vertical alignment
In addition to aligning text horizontally, CSS enables you to align text to objects around it via the vertical-align property.
The vertical-align property supports the following values:
The following code and the output shows the effect of each value:
The effect of various vertical-align settings. Borders were added to the text to help contrast the alignment.
Of course, text isn’t the only element affected by an element’s vertical-align setting—all elements that border the affected element will be aligned appropriately. The image has the vertical-align property set to middle. Note how the midpoint of both elements is aligned.
The vertical-align property can be used to vertically align most elements.
HTML Related Interview Questions
|XML Interview Questions||HTML 4 Interview Questions|
|HTML Interview Questions||HTML 5 Interview Questions|
|HTML DOM Interview Questions||Java Interview Questions|
|CSS Interview Questions||Java Abstraction Interview Questions|
|Dynamic HTML Interview Questions||XHTML Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.