Jump to content

Archived

This topic is now archived and is closed to further replies.

michaellunsford

HELP auto-centering not working

Recommended Posts

This table is supposed to be centered. It's coming up left justified. I remove the doctype line and it works fine. What am I missing?

[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
</head>
<html>
<body>
<div style="margin-left:auto; margin-right:auto; width:765;"><table width="765" height="857" border="1" cellpadding="0" cellspacing="0"><tr><td width="765">hi there</td></tr></table></div>
</body>
</html>[/code]

Share this post


Link to post
Share on other sites
Just keep in mind that that doesn't work in IE6 and below. You'd need to also include a wrapper <div> that has text-align: center;.

Share this post


Link to post
Share on other sites
[!--quoteo(post=380353:date=Jun 5 2006, 09:06 PM:name=moberemk)--][div class=\'quotetop\']QUOTE(moberemk @ Jun 5 2006, 09:06 PM) [snapback]380353[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Just keep in mind that that doesn't work in IE6 and below. You'd need to also include a wrapper <div> that has text-align: center;.
[/quote]
Actually it does as long as there is a valid doctype defined and that there is is width also defined for the element you are centering then your good to go, which michaellunsford has both of those!

Share this post


Link to post
Share on other sites
Really? I'd always thought it didn't work like that. Learn something new every day, it seems.

Share this post


Link to post
Share on other sites
Thanks for the dialog, guys. I am still learning the CSS ropes, and this kind of stuff certainly helps me know what to expect, and what to do if it happens.

one thing that I really don't understand is the #wrapper thing. I have tried numerous examples that have the #wrapper tag, but removing it never seems to do anything.

most of the examples are "html, body #wrapper". So, exactly what does the "wrapper" part do?

Share this post


Link to post
Share on other sites
#wrapper is styling a html tag in your document that has an id of wrapper like this:
[code]<div id="wrapper">somethiing here</div>[/code]
Then in your css you can use this:
[code]#wrapper {
    font-sixe: 20px; /*Change font size*/
}[/code]
With will change the font size of that div tag only.

Usually web devs name a div tag the container or wrapper which holds all of the pages content, which then the developer uses css to center the site.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.