In IE6 the container on my home page doesn't center. On IE7, Safari and Foxfire, it's fine and on all other pages on IE6, it's also fine. Could there be something in the HTML of the home (index.html) page that is saying to ignore the margin-left, margin-right:auto in the Container CSS? I have compared the index HTML with the HTML of the correct pages and can't see anything that could cause this. This is the last problem I need to solve to get my site to look right in IE6. Any suggestions? www.napackdesign.com

Dani AI

Generated

Nice catch by — that XML prolog at the very top is the likely culprit. Internet Explorer 6 decides standards vs. quirks mode from the first bytes it sees; an XML declaration (or any invisible bytes before the DOCTYPE, like a UTF-8 BOM or stray whitespace) can push IE6 into quirks-mode and break margin: 0 auto centering. Removing the prolog fixed it for , which fits this behavior.

Practical checklist to avoid this in future:

  • Make the DOCTYPE the first thing in the file. No XML prolog, no whitespace, and no BOM before it.
  • If you need XHTML syntax, either serve as application/xhtml+xml to browsers that support it, or omit the XML prolog when serving as text/html for older IE.
  • Verify the container has an explicit width (required for margin:auto centering) and, if IE6 still misbehaves, trigger hasLayout (zoom:1 or display:inline) on the container as a fallback.
  • Use an editor that can show/remove the UTF-8 BOM or open the file in a hex viewer to confirm no hidden bytes.
  • Test with an IE6 emulator or IETester to reproduce the issue after fixes.

Keeping the DOCTYPE as the very first bytes usually prevents these subtle cross-browser layout traps.

Recommended Answers

All 2 Replies

Bnapack,

Home page has an xml declaration at the top - the other pages don't.

Try getting rid of it.

Airshow

Thanks, Airshow. Deleting the XML declaration took care of it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.