Text alignment

Last chapter, we learned the P tag to create paragraphs. However, you don't have to stop at simple flush-left paragraphs. You can easily cause paragraphs to be centered (aligned center), or flush-right (aligned right), by adding the ALIGN attribute to your paragraph tags.

Here are some examples, using part of a recipe for peanut sauce:

<P ALIGN="CENTER">Heat curry paste with 1/4 c. coconut milk. 
Simmer 1 - 2 minutes. Some oil should foam to the top. Add fish 
sauce and sugar. Bring to a boil again and add remaining 
coconut milk. Add peanuts, bring to a boil and simmer 
slowly for 15 minutes. Cool slightly and serve with satay.</P>

This is what that code looks like:

Heat curry paste with 1/4 c. coconut milk. Simmer 1 - 2 minutes. Some oil should foam to the top. Add fish sauce and sugar. Bring to a boil again and add remaining coconut milk. Add peanuts, bring to a boil and simmer slowly for 15 minutes. Cool slightly and serve with satay.

<P ALIGN="RIGHT">Heat curry paste with 1/4 c. coconut milk. 
Simmer 1 - 2 minutes. Some oil should foam to the top. Add fish 
sauce and sugar. Bring to a boil again and add remaining 
coconut milk. Add peanuts, bring to a boil and simmer 
slowly for 15 minutes. Cool slightly and serve with satay.</P>

This is what that code looks like:

Heat curry paste with 1/4 c. coconut milk. Simmer 1 - 2 minutes. Some oil should foam to the top. Add fish sauce and sugar. Bring to a boil again and add remaining coconut milk. Add peanuts, bring to a boil and simmer slowly for 15 minutes. Cool slightly and serve with satay.

Notice that you don't have to repeat the ALIGN attribute in the closing tag. Just /P is enough.

You could also use ALIGN="LEFT", but it's not necessary, since text aligns left by default.

You can use the ALIGN attributes in heading tags as well, and elsewhere. Try it and see!


<<-------- p r e v // a i w e b // n e x t -------->>