Center align a DIV without

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Is there a way to center the following div without using the <center>

<body bgcolor="#FFFFFF">
<div id="Test" style="background-color:#000000; color:#ffffff; width:
80%; text-align:center; line-height:100px;">Hello</div>

I want the div AND the text in the div to be aligned to the center.


(It's probably REALLY simple and I'll be quite embarassed that I
asked... but it's been one of "THOSE" days...)

Re: Center align a DIV without

Quoted text here. Click to load it

1. Use CSS not HTML attributes.
2. Set foreground and background colours together to avoid clashes
with user defaults.

Quoted text here. Click to load it

It's not 100% obvious and hence it is a FAQ. Set margin-left and
margin-right to auto.

Make sure that your doctype is triggering standards mode or IE won't


Re: Center align a DIV without

In article

Quoted text here. Click to load it

The first two pages of


should give you a good idea of how to do both these things.


Re: Center align a DIV without

dorayme scribed:

Quoted text here. Click to load it

That seems like a very helpful site. Is there a navigation page? The home
page seems to have only a mail form.

Ed Jay (remove 'M' to reply by email)

Win the War Against Breast Cancer.
Knowing the facts could save your life.

Re: Center align a DIV without

Quoted text here. Click to load it

The things on this server are mainly just sets of self-contained pages.
This set seems short enough not to need a menu but if I grow it, I guess
I will put some navigation beyond the pages menu at top and bottom.

I am a bit worried at the slightly artificial connection of things under
the topic of centring in this set. What else should I put?

* My views on the aesthetics of centring?

* My take on why centring has such an appeal (I reckon it has to do  
with the importance of left/right symmetry in animal evolution)?

* Perhaps an attempt at humorous, maybe even florid writing, about why
archery targets have the bull's eye in the centre; after all, even a
bull does not have its eye in the dead centre of its bulk, neither
mass-fully nor geometrically speaking? And besides, it has two eyes.

* Why don't dart boards have two bulls eyes like bulls, you could get
100 only if you can throw two darts at once each landing on different
eyes? Perhaps I could make and market a special and more rational
dart-board, closer to bull. (psst, Boji, wanna send me some $buckeroos
as an advance payment for one of these?)


Site Timeline