Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 08:20 PM
Hal Canary
Guest
 
Posts: n/a
Default 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?
  #2  
Old July 20th, 2005, 08:20 PM
Els
Guest
 
Posts: n/a
Default 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
Default 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
Default 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
Default 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


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles