HTML Alignment Tag
Aligning text, images, paragraphs, etc... is very simple. You do it by using the HTML alignment tag in the opening tag of the element you want to align. You can either Align left, center or right. To add the value to your element, add align="VALUE" to the opening tag where VALUE is left, center or right.
Here's an example where we use the HTML alignment tag in a paragraph to align the text to the right:
|
<html> <head> <title>html alignment tag</title> </head> <body> <p align="right">The text in this paragraph will be aligned to the right.</p> </body> </html> |
Aligning Images, Divs, paragraphs, etc
Since we haven't yet covered images in the tutorial, I won't go too much into detail about image alignment but i'll still give you the code incase you need it now. Aligning images, divs,paragraphs or any other element, you just add align="value" anywhere in the opening tag. Here's an example of an image alignment where I put the value at the end of the opening tag:
|
<html> <head> <title>html alignment tag</title> </head> <body> <img src="photo.jpg" align="right">This image will be aligned to the right of the screen and text will flow to it's left. Since the image HTML tag doesn't need to be closed, there is no closing tag. </body> </html> |
Special HTML alignment tag "center"
There is a special tag that can be used to center multiple elements at once. All you need to do it put all the content you want centered between <center> and </center> tags. You can put multiple paragraphs or even a whole page within those tag if you want. Here's an example:
|
<html> <head> <title>html alignment tag</title> </head> <body> <center> <p>This paragraph will be aligned to the center.</p> <p>This paragraph will also be aligned to the center.</p> </center> <p>This paragraph will not be included in the center tag so will be aligned to default or whatever you set it to.</p> </body> </html> |
| Back HTML page formatting | Next HTML Quote |