Interspire Product Knowledge Base

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Remove from favorites Remove from favorites

Remove Highlighting Remove Highlighting

Edit this Article

Export to PDF

User Opinions (0 votes)

No users have voted.

How would you rate this answer?

Thank you for rating this answer.

HTML Examples #2 - How to Center Anything

There are two ways to align something to the center of the container that it is in.

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:

and then call it like this:

<div>Uncentered text</div>
<div class="CenterMe">Centered text</div>

Related Articles

No related articles were found.


No attachments were found.

Powered by Interspire Knowledge Manager - World's #1 Best Selling FAQ and Knowledge Base Software