Text alignment (left, right, left, right, left, right....)Posted Jun-23-06 20:45:59 PDT Updated Jun-23-06 20:46:47 PDT No, we're not talking about drill sergeant orders here (left, right, left, right...). Rather we are going to look at the alternative to the html attribute align="xxxxxxx". The CSS property, text-align lets you control where the text goes in the HTML tag it is applied to. Possible values are left, right, center, and justify. In the following examples, I'm using a tag with a border to better show the alignment. First we have text-align:center. This text is going to be aligned center within it's containing div tag so you can see how it lays out Let's show the other forms for comparison: This
text is going to be aligned right within it's containing div tag so
you can see how it lays out This
text is going to be justified within it's containing div tag so
you can see how it lays out and for completeness, let's see left alignment which is the default This
text is going to be aligned left within it's containing div tag so
you can see how it lays out I forced the justified case to have a width:20% so that you could better see the justification taking place. Usually, justified text is harder to read on computers so try to leave it for books where a ragged right margin is not desired. Cheers "I am an eBay employee. The opinions expressed in my blog are my own, and not eBay's." |