By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,453 Members | 961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,453 IT Pros & Developers. It's quick & easy.

Center align a DIV without <center> tags

P: n/a
Is there a way to center the following div without using the <center>
tags?

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

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

Thanks...

(It's probably REALLY simple and I'll be quite embarassed that I
asked... but it's been one of "THOSE" days...)
Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Jun 18, 2:43*pm, DiamondEagle <and...@webmail.co.zawrote:
Is there a way to center the following div without using the <center>
tags?

<body bgcolor="#FFFFFF">
1. Use CSS not HTML attributes.
2. Set foreground and background colours together to avoid clashes
with user defaults.
<center>
<div id="Test" style="background-color:#000000; color:#ffffff; width:
80%; text-align:center; line-height:100px;">Hello</div>
</center>
</body>

I want the div AND the text in the div to be aligned to the center.
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
co-operate.

Steve

Jun 27 '08 #2

P: n/a
In article
<13**********************************@34g2000hsf.g ooglegroups.com>,
DiamondEagle <an****@webmail.co.zawrote:
Is there a way to center the following div without using the <center>
tags?
The first two pages of

<http://netweaver.com.au/centring/>

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

--
dorayme
Jun 27 '08 #3

P: n/a
dorayme scribed:
>In article
<13**********************************@34g2000hsf. googlegroups.com>,
DiamondEagle <an****@webmail.co.zawrote:
>Is there a way to center the following div without using the <center>
tags?

The first two pages of

<http://netweaver.com.au/centring/>

should give you a good idea of how to do both these things.
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.
http://www.breastthermography.info
Jun 27 '08 #4

P: n/a
In article <ji********************************@4ax.com>,
Ed Jay <ed***@aes-intl.comwrote:
dorayme scribed:
In article
<13**********************************@34g2000hsf.g ooglegroups.com>,
DiamondEagle <an****@webmail.co.zawrote:
Is there a way to center the following div without using the <center>
tags?
The first two pages of

<http://netweaver.com.au/centring/>

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

That seems like a very helpful site. Is there a navigation page? The home
page seems to have only a mail form.
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?)

--
dorayme
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.