467,165 Members | 1,015 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,165 developers. It's quick & easy.

Question about centering <div>s.

<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
  • viewed: 3326
Share:
4 Replies
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
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
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
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.

Similar topics

8 posts views Thread by Daniel Hansen | last post: by
1 post views Thread by Ron Bott | last post: by
3 posts views Thread by CMAR | last post: by
3 posts views Thread by John Pote | last post: by
8 posts views Thread by CJM | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.