Oh, fer cryin’ out loud. Close the darn tag!

Wednesday, 22 July 2009 09:18 by james

I’ve been working on a side project for a while now. A big AJAX-y web application with tons of moving parts. Last night I was getting ready to publish a version for the client to review when I noticed something odd when viewing in Internet Explorer 8. It started out peculiar, turning out to be extremely frustrating.

How a portion of the page looked in Firefox 3.5

 ff_render

 

And how the same page looked in Internet Explorer 8 (with and without Compatibility Mode) Notice how the font style changes at “State”.

ie_render

I spent a good amount of time trying to figure out what the heck was going on. Thinking I had hosed a style somewhere, I opened up Firebug and inspected the element. This is what I saw. Ok, looks normal to me.

ff_html

But using Internet Explorer’s Developer Tools, I saw this. Notice how the span does not close, and the rest of the elements are a child of the span tag.

ie_html

So, going over the HTML in the ASPX page, I find this, I hadn’t closed the span tag properly. DOH!

badcode

Fixing the markup like such, makes the page render properly.

goodcode

So, is this a bug or a feature of Internet Explorer 8? Or, a bug or a feature of Firefox 3.5?  For me the moral of the story is to make sure that all my block element tags are properly closed.

Time to code,

James

Comments

July 22. 2009 09:35

I had even more frustration when I did the same thing in the head title tag.
<head><title/><head> will prevent IE from rendering anything!

Dennis

James Johnson

My views and opinions on running a .NET User Group, web development, evangelizing, mentoring, utilizing the latest technologies, living as a gringo in a Latin family, and, of course, life in general.

Join BizSpark

BizSpark provides qualified Startups with FREE* software and support getting their idea up and running.
There is no charge for signing up. However a minimal fee of $100 is required when you leave the program.

Recent Comments