views:

157

answers:

2

I hope I'm not breaking any rules by asking a question that pertains to a project I'm working on. If you view my page here and view it in Firefox and again in Internet Explorer, the width of the main content boxes differs. In Firefox, everything aligns perfectly with the advertisement at the top of the page, but in IE, the width of the content boxes seems to fall short by about 20 or so pixels.

My question is obvious by now, but what is causing the width in IE to fall short, and what would a simple solution be?

If I happen to be breaking the rules by asking a question that is not generic enough to benefit others, then allow me to rephrase it; what would be the best approach to solving visual differences between browsers? Should I use a separate CSS file for IE, or is there a way to define lines in my CSS file that only get rendered by a specific browser?

It would be best if someone could provide me with the necessary CSS to align things properly, but I would be more than happy to learn about how to make the CSS dynamic (if that's possible).

Thanks everyone. :)

+8  A: 

Your HTML is not well formed. You need <html>, and <title> should be in <head>. Most importantly, you need a DOCTYPE so that browsers will use standards mode instead of quirks mode when rendering. Quirks mode is the cause of the differing widths.

The HTML 5 doctype is: <!DOCTYPE html> and should be the first line of your HTML file. Below is a minimum HTML file.

<!DOCTYPE html>
<html>
    <head>
        <title>Document</title>
    </head>
    <body>
    </body>
</html>
CalebD
Wow!!! A++++! Adding the <!DOCTYPE html> instantly solved the problem. It caused a couple other unwanted side effects but that will be a breeze to fix; at least now things look identical in both browsers.
Joe Majewski
Once again, thank you very much. You have no idea how long I was working on getting those small visual differences to go away. I had no idea that a doctype was so powerful.
Joe Majewski
@Joe - If you use Firefox, you'll probably find the HTMLTidy plugin rather useful: http://users.skynet.be/mgueury/mozilla/
indiv
Well, it's not the quirks mode itself that causes the size differences, but the box model bug (http://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug) that appears in IE in quirks mode.
Guffa
@Joe - You're welcome. indiv is right, HTML tidy is useful, along with Firebug, the Web Developer Toolbar, ColorZilla, and many other addons. For a good but basic HTML guide, check out http://www.htmldog.com/
CalebD
@Guffa - Yeah you're right. I was being brief. @Joe - Check out Guffa's link if you're interested in understanding more about web development.
CalebD
I'm checkin' it out right now. I'm a slave to Firebug, though. If I'm working on a computer that doesn't have it I tend to constantly go and click at the corner of the browser by force of habit. I believe myself to be an excellent programmer, but when it comes to web design I fall apart. I've been getting better, though. Three years ago and I wouldn't be able to find a reason in world to bother using CSS. I would use tables for just about everything, including layout. Now I'm much better about organizing my content and using div blocks governed by CSS to make things look pretty.
Joe Majewski
A: 

try using

box {
    width: 100%;
}
choise