Hey I would love to know what you think while reading my posts. Please comment!.

Force IE9 into Quirks Mode

Just a quick one, but something I only noticed recently.

Adding any HTML comment block above your <!doctype html> tag will throw IE9 into Quirks Mode!

<!-- -->
<!DOCTYPE html>
 
<html>
<head>
    <title>QuirksMode</title>
</head>
<body>
    <div>
        Quirks Mode
    </div>
</body>
</html>

HA!

Now I know this isn't good HTML markup anyway, but at times I add comment blocks while debugging my code, e.g

Response.Write("<!-- " & someVariable & " -->")

99% of the time I have never seen a problem with this, but one project completely threw me as the web page with this comment block looked completely broken in IE9. I sent hours inspecting the DOM in Chrome, Firefox, Opera, IE, updating the HTML/CSS, everything I could think of to find out why the page was broken. Eventually I let a fresh set of eyes look at the problem, and straight away he said "Maybe the comment blocks at the top are affecting it?"

Sure enough!

If you found this blog post useful in anyway, or would like to make any suggestions, then please leave a comment! I would greatly appreciate it!

About Me

Tim James I'm Tim, a web applications developer from Glasgow, Scotland. Currently working for Kingfisher Systems Ltd, building bespoke systems within the Car Auction industry.

  • C#
  • VB.NET
  • ASP.NET
  • .NET MVC
  • Web API
  • Razor
  • HTML5
  • CSS3
  • jQuery
  • WCF
  • SQL
  • knockout.js
  • Angularjs
  • AJAX
  • APIs
  • SignalR
Why not follow me on twitter? Follow me on Twitter