Connecting Tech Pros Worldwide Help | Site Map

Question about centering <div>s.

  #1  
Old July 20th, 2005, 08:20 PM
Hal Canary
Guest
 
Posts: 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?
  #2  
Old July 20th, 2005, 08:20 PM
Els
Guest
 
Posts: n/a

re: Question about centering <div>s.


Hal Canary wrote:
[color=blue]
> <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?[/color]

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 vão. O resto é imperfeito.
- Renato Russo -
  #3  
Old July 20th, 2005, 08:20 PM
Hal Canary
Guest
 
Posts: n/a

re: Question about centering <div>s.


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

Thanks. This:

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

works. How non-intuitive.

  #4  
Old July 20th, 2005, 08:20 PM
Els
Guest
 
Posts: n/a

re: Question about centering <div>s.


Hal Canary wrote:
[color=blue]
> On Tue, 13 Jul 2004 23:14:05 +0000, Els wrote:[color=green]
>> Hal Canary wrote:[color=darkred]
>>> ... Does anyone have any ideas?[/color]
>>
>> http://locusmeus.com/html-css/centeringpage.html
>> It's about a page, but the same thing goes for a div.[/color]
>
> Thanks. This:
>
> <div style="margin:auto; border:1px solid; width:750">
>
> works.[/color]

Don't forget the text-align:left to counter the text-
align:center on the parent div :-)
[color=blue]
> How non-intuitive.[/color]

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 vão. O resto é imperfeito.
- Renato Russo -
  #5  
Old July 20th, 2005, 08:20 PM
Jan Roland Eriksson
Guest
 
Posts: n/a

re: Question about centering <div>s.


On Tue, 13 Jul 2004 18:19:59 -0500, Hal Canary <halcanary@yahoo.com>
wrote:
[color=blue]
>...This:
> <div style="margin:auto; border:1px solid; width:750">
>works...[/color]

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


Closed Thread