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

Question about centering <div>s.

P: n/a
<div align="center"> does not seem to be identical to <div
style="text-align:center">, as this example

http://home.earthlink.net/~canaryh3/example.html

points out. Yet the 'align' attribute is deprecated. Does anyone
have any ideas?
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Els
Hal Canary wrote:
<div align="center"> does not seem to be identical to <div
style="text-align:center">, as this example

http://home.earthlink.net/~canaryh3/example.html

points out. Yet the 'align' attribute is deprecated. Does
anyone have any ideas?


http://locusmeus.com/html-css/centeringpage.html
It's about a page, but the same thing goes for a div.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vo. O resto imperfeito.
- Renato Russo -
Jul 20 '05 #2

P: n/a
On Tue, 13 Jul 2004 23:14:05 +0000, Els wrote:
Hal Canary wrote:
... Does anyone have any ideas?


http://locusmeus.com/html-css/centeringpage.html
It's about a page, but the same thing goes for a div.


Thanks. This:

<div style="margin:auto; border:1px solid; width:750">

works. How non-intuitive.

Jul 20 '05 #3

P: n/a
Els
Hal Canary wrote:
On Tue, 13 Jul 2004 23:14:05 +0000, Els wrote:
Hal Canary wrote:
... Does anyone have any ideas?
http://locusmeus.com/html-css/centeringpage.html
It's about a page, but the same thing goes for a div.


Thanks. This:

<div style="margin:auto; border:1px solid; width:750">

works.


Don't forget the text-align:left to counter the text-
align:center on the parent div :-)
How non-intuitive.


It's called "box-model".
I find it quite intuitive actually, but then again, I didn't get
into HTML layout too much before I met CSS.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vo. O resto imperfeito.
- Renato Russo -
Jul 20 '05 #4

P: n/a
On Tue, 13 Jul 2004 18:19:59 -0500, Hal Canary <ha*******@yahoo.com>
wrote:
...This:
<div style="margin:auto; border:1px solid; width:750">
works...


No it does not "work" unless your browser is buggy and lies to you.

How can a spec conforming user agent know if you want the width to be
750 bananas, 750 miles, 750 lightyears or... 750px (which is probably
what you intended it to be?)

--
Rex
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.