Jump to content

centering at very top of page


novicenate

Recommended Posts

I want to have divisions centered on the page no matter if the screen is at 800x600 or 1280x1048 or whatever. I found the code to make it centered...margin:0 autobut when I put this in, the top margin comes down to about 4 pixels. What am I doing wrong? I want it to be flush with the top of the page.thanks

Link to comment
Share on other sites

First of all, I hope you had a semi-colon after that. It should be listed in the css code as :

margin:0 auto;

Notice the trailing semi-colon.And without seeing your page, would you happen to have a top text header up there? Remove the margins on those items as well. some Browsers stop the page from attaching to the very top if the contained element still has a margin. Use padding instead to force the header down to suit the layout.We might be able to assist you further if you post a link or the page code. thanks.

Link to comment
Share on other sites

depending on your doctype this will not work in IEI always do this so I never have to worry about the doctype

body{   margin: 0px;   padding: 0px;   text-align: center;}div.wrapper /*(or something)*/{   width: 800px;   margin: 0px auto;   text-align: left;}

BTW you need to give the div a width inorder to center it else it is already taking 100% width.

Link to comment
Share on other sites

%99.9 of the time I do to, I use XHTML 1.0 strict but sometimes I am forced to downgrade the doctype due to client needs (or due to horrible third-party code) and then some CSS behaves different in IE.Sometimes you just can't have the ideal situation. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...