Fandom

HTML & CSS Wiki

Text-align

649pages on
this wiki
Add New Page
Comments0 Share

The text-align property is used in CSS and certain HTML elements. It describes how inline content (eg. text) is aligned in its parent block element. This property does not control the alignment of block elements itself, only their inline content.

Values

  • left - The inline contents are aligned to the left edge of the line box.
  • right - The inline contents are aligned to the right edge of the line box.
  • center - The inline contents are centered within the line box.
  • justify - The text is justified. Text should line up their left and right edges to the left and right content edges of the paragraph.
  • start - The same as left if direction is left-to-right and right if direction is right-to-left.
  • end - The same as right if direction is left-to-right and left if direction is right-to-left. (Requires Gecko)


Mozilla Extensions
  • -moz-center - Centers inline and also block content.
  • -moz-left - Aligns inline and also block content.
  • -moz-right - Aligns inline and also block content.


To apply this in HTML, use:

<div style="text-align:right;">Text on the right</div>

That will produce:

Text on the right

To apply this in CSS, in the h1 element for example, use:

h1 {
    text-align:center;
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.