B.107. text-align

This property sets the horizontal alignment of text and other inline content within a block element.

If you're looking for a way to set the horizontal alignment of a block (e.g. to center it on the page), you should instead use the margin-left, margin-right, left, and right properties to achieve the desired effect (e.g. you can center a block horizontally by setting its left and right margins to auto).

Inherited: Yes

See also: Section B.108text-align-last, Section B.120vertical-align

B.107.1. Value

This property supports the following constant values:

  • center

  • justify

  • left

  • right

center, left, and right are self-explanatory. justify should be familiar to users of word processors; it causes the words on each line to be spaced out so that each line starts and ends against the edge of the content box, with the exception of the last line.

New in CSS2, you can specify a string for text in table cells to align on. E.g. the value "." would cause values in table cells to be aligned so that the decimal points all line up vertically. This type of value has only an effect on table cells; other elements will treat it as the initial value.

Initial value: depends on the language of the browser and/or the element

B.107.2. Compatibility

CSS Version: 1 (string alignment for tables added in CSS2)

This property is supported by all CSS-compatible browsers.

In older browsers (most version 4 browsers), justify behaves the same as left; however, this is allowable under the CSS2 standard.

String alignment in table cells is not supported by any currently-available browser.

B.107.3. Example

This style rule will justify text within the body and all child elements, unless otherwise specified (thanks to inheritance):

body {
  text-align: justify;
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.95.38