The text-align CSS property describes how inline content like text is aligned in its parent block element. text-align does not control the alignment of block elements itself, only their inline content.
Overview tablestart, or a nameless value that acts as left if direction is ltr, right if direction is rtl, if start is not supported by the browser.
textAlign
text-align: <string>
text-align: center
text-align: end
text-align: justify
text-align: left
text-align: match-parent
text-align: right
text-align: start
text-align: start end
left
if direction is left-to-right and right
if direction is right-to-left.
right
if direction is left-to-right and left
if direction is right-to-left.
start
and end
are calculated according the parent’s direction and are replaced by the adequate left
or right
value.
start
alignment of the first line and any line immediately after a forced line break; and end
alignment of any remaining lines not affected by text-align-last.
This just shows the four possible types of text-alignment.
<p class="left"> This paragraph is aligned to the left. </p>
<p class="centered"> This paragraph is centered. </p>
<p class="right"> This paragraph is aligned to the right. </p>
<p class="justified">This paragraph needs to be really long in order to show how to justify text. It only works because we set a width for this paragraph though.</p>
.left { text-align: left;}
.cenetered{ text-align: center;}
.right { text-align: right;}
.justified { width: 200px; text-align: justify;}
Notes
The standard-compatible way to center a block itself without centering its inline content is setting the left and right margin
to auto, e.g.: margin:auto;
or margin:0 auto;
or margin-left:auto; margin-right:auto;
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4