So how exactly does one center any div, without making use of tables I’m absolutely lost here. Thanks for virtually every help.
... < head> < style type=" text/css" media=" screen" > html code, body text-align: middle; #centre width: 760px; text-align: left; margin: 0 automobile; < /style> < /head>...
< div id=" centre" > This block element is going to be centred in the actual browser window. < /div>
The < DIV> tag is similar to < P> tag. Just set this attribute ALIGN=" center" as well as you’re on.
< div align=" center" > this text stands in the centre. < /div>
Even so, that’s not W3C good..
Ok, I’ve tried every one of those things, but I didn’t make use of the margin: 0 automobile; line. That won’t affect the centering have to it
body text-align: middle; background-color: #2C4762; font-family: verdana, arial; font-size:. 8em; . major width: 900px; levels: 100%; border-width: 1px; border-color: #546A80; border-style: strong; background-image: url(.. /images/sky. jpg); background-repeat: no-repeat; backroud-color: #2C4762;
Subject to the code, it could possibly. More so around other resolutions. Give it any shot at anything better or scaled-down then what you’re running right now.
Yes and also, margin: 0 automobile; basicly means…
margin-top: 0; margin-bottom: 0; margin-left: automobile; margin-right: auto;
Using auto lets the browser to enter the excess breathing space either side pushing your primary layout table/div in to the centre of your page.
The text-align: center; is perfect for browsers that interpret the CSS wrong/differently.
Men, I thank you much. If you might be ever in The islands, I’ll buy a few Cigars.
/me alterations his vacation blueprints *grins*
haha. MY SPOUSE AND I bet. A good cigar is a great incentive I know a student cubans!!!: rambo:
The div align=" center" approach wouldn’t ever work (and its valid).
Here is why: by default, block elements (div) expand to the size of the containers. by giving it the feature align=" center" you happen to be centering the aspects inside the div, not necessarily the div itself. So what do you do First cause it to smaller than the actual window, then make use of the technique listed above. The text-align: middle; part is to support IE5, but this margin: 0 automobile; is where some individuals at.
Another method is always to take the div offer it this:
position: total; left: 50%; margin-left-1/2 dimension of containerpx;
Although this process tends to can interesting things after the resolution gets smaller approach design.
Not necessarily under XHTML Rigid. This code will not likely validate.
<! DOCTYPE html code PUBLIC " -//W3C//DTD XHTML ONE. 0 Strict//EN" " http: //www. w3. org/TR/xhtml1/DTD/xhtml1-strict. dtd" > < html code xmlns=" http: //www. w3. org/1999/xhtml" xml: lang=" en" lang=" en" > < head> < meta http-equiv=" Content-Type" content=" text/html; charset=iso-8859-1" /> < title> Untitled Document< /title> < /head> < body> < div align=" center" > This can not validate< /div> < /body> < /html>