473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
4 3464
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 vão. 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 vão. 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
8
by: Daniel Hansen | last post by:
I know this must seem totally basic and stupid, but I cannot find any reference that describes how to control the spacing between <p>...</p> and <div>...</div> blocks. When I implement these on a...
1
by: Ron Bott | last post by:
I have a fixed size <div> I would like to display in the center of a browser window. To get the horizontal alignment is no problem using 'margin-left: auto' and 'margin-right: auto' but I cannot...
3
by: CMAR | last post by:
To center my <div>, I am currently using something like <div id="navcontainer" align="center"> This centers fine, but is deprecated code. I have seen these two solutions recommended. 1) ...
3
by: John Pote | last post by:
1. Horizontal centering a <divin browser window. The current trend seems to be to place page content in a fixed width area in the middle of the browser window. How is this achieved? If I use a...
3
by: rsteph | last post by:
I'm using two divs to create a shadowed-box type effect. Within the top div I want to put an image. I can get the image to center right to left, but not top to bottom. I'm making a series of boxes,...
8
by: CJM | last post by:
I've inserted a new banner in an existing page and I want the banner image to be centered (horizontally) within its container. I'm not bothered whether the accompanying line of text is restricted...
4
by: harryusa | last post by:
I am trying to center 2 images concentrically which are z-indexed to lay on top of each other making an image with a border from another image that has a transparent center. I need the images to be...
8
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.