Jump to content


Photo

HELP auto-centering not working


  • Please log in to reply
6 replies to this topic

#1 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 05 June 2006 - 07:03 PM

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?

<!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>


#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 05 June 2006 - 07:15 PM

nevermind...

finally figured out that width requires px.

765px

what a waste of two hours.

#3 moberemk

moberemk
  • Members
  • PipPipPip
  • Advanced Member
  • 695 posts

Posted 05 June 2006 - 08:06 PM

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;.
Disclaimer: No matter how harsh I may be, I'm always IMO only.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 June 2006 - 02:50 PM

[!--quoteo(post=380353:date=Jun 5 2006, 09:06 PM:name=moberemk)--][div class=\'quotetop\']QUOTE(moberemk @ Jun 5 2006, 09:06 PM) View Post[/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!

#5 moberemk

moberemk
  • Members
  • PipPipPip
  • Advanced Member
  • 695 posts

Posted 06 June 2006 - 09:25 PM

Really? I'd always thought it didn't work like that. Learn something new every day, it seems.
Disclaimer: No matter how harsh I may be, I'm always IMO only.

#6 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 10 June 2006 - 03:32 PM

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?

#7 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 10 June 2006 - 04:21 PM

#wrapper is styling a html tag in your document that has an id of wrapper like this:
<div id="wrapper">somethiing here</div>
Then in your css you can use this:
#wrapper {
    font-sixe: 20px; /*Change font size*/
}
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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users