The first is using HTML:
Some HTML objects have the ability to align themselves on the page using the align="center" tag and some do not.
Examples of some HTML objects that have the align center capability:
div, table, tr, td, h1 (h2, h3, etc.)
Examples of some HTML objects that do not have the align center capability:
img, span, iframe, body, form, input, strong
Here's an example:
Uncentered text
<div align="center">Centered text</div>
<table><tr><td>Uncentered Table</td></tr></table>
<table align="center"><tr><td>Centered Table</td></tr></table>
and here's what it looks like:
Uncentered Text
Centered text
Uncentered table |
Centered table |
The other way is to use CSS. CSS's align-center feature is "text-align", which is sort of a misnomer, since it will center images and other things too.
There are two ways to apply CSS, either through an external file with an extension of ".css" or by applying the CSS styling "in-line".
In-line example:
<div>Uncentered text</div>
<div style="text-align:center">Centered text </div>
Uncentered text
Centered text
External example:
Place this in your external CSS file to create a class:
.CenterMe{
text-align:center;
}
and then call it like this:
<div>Uncentered text</div>
<div class="CenterMe">Centered text</div>