Centering - Using text-align
~10 mins
Using text-align
- The most common and easiest type of centering is that of lines of text in an element.
- CSS has the rule
text-align:centerfor this purpose:
<p>Lorem ipsum</p>
</div>
p {
text-align: center;
}
- This does not work for centering entire block elements.
text-aligncontrols only alignment of inline content like text in its parent block element.