I'm going nuts. I just can't find a solution for this. This is how it SHOULD look like:
The navigation will have background image (full width), but the menu itself should be centered. Same for the footer. And that's my problem. This is how it currently looks:
The red box in the background is the footer, which of course should be at the bottom below the blue box.
That's my HTML:
div id="menu" div id="menu-content" /div /div
div id="header" /div div id="conten" /div div id="footer" /div
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" > <head> <meta http-equiv="content-language" content="en" /> <title>Test page</title> </head> <body> <div id="container"> Lorem ipsum </div> </body> </html>
CSS code:
body { /*some browsers add margins and padding by default, remove them*/ margin:0px; padding:0px; } #container { width:800px; height:600px; /*visual aid so we can see the div*/ border:1px solid #000; /*center div*/ margin:0 auto; }
Text align center, this method works for internet explorer and requires you to put "text-align:center" css attribute in your "body" style and later reset it by adding "text-align:left" (or right) in your divs (or other layout structure). This method works on all versions of internet explorer
body { /*some browsers add margins and padding by default, remove them*/ margin:0px; padding:0px; /* center everything*/ text-align:center; } #container { /* reset text centering*/ text-align:left; width:800px; height:600px; /*visual aid so we can see the div*/ border:1px solid #000; }
By combining the two methods above you can center your layout on all browsers including internet explorer
danidallia123 has given the right solution. There are really browsers that add margins and paddings as defaults. These should be eliminated to put things in proper place. Learned this in Millionaire Mind Intensive Seminar