Dreamweaver causing Quirks Mode in Internet Explorer
Asked Answered
I

2

4

I use Dreamweaver to develop Web sites. I use the templates feature extensively as it helps to make things easier maintaining conformance.

However, I notice that Dreamweaver adds the following code before the doctype:

<!-- InstanceBegin template="/templates/web-public-user-home.dwt" codeOutsideHTMLIsLocked="false" -->

This is throwing my IE into Quirks mode for obvious reasons (i.e. comment before the doctype). Is there a way of dealing with this?! Below is my doctype.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Regards,

Irruption answered 9/6, 2011 at 14:19 Comment(0)
I
3

Ok, I figured this out.

Because of the extensive IE-compliance tweaking I'm doing, I was using conditional comments. However, I was using them on the html tag. There's nothing wrong with this in principle but Dreamweaver won't handle your live template updates properly when you do this (It will place the Dreamweaver-specific template lock code first before the doctype, thereby ensuring that your pages will throw Quirks mode in IE).

So what I did was move my conditional comment system away from the html tag, instead using them immediately after your opening body tag and immediately before your closing body tag like so:

<body>
<!--[if IE 6 ]> <div id="ie" class="ie6"> <![endif]-->
<!--[if IE 7 ]> <div id="ie" class="ie7"> <![endif]-->
<!--[if IE 8 ]> <div id="ie" class="ie8"> <![endif]-->
<!--[if gt IE 8 ]> <div id="ie"> <![endif]-->
<!--[if !IE]><div id="not-ie"> <![endif]-->

{YOUR HTML CODE}

  </div>
</body>

This way, Dreamweaver places the doctype and html tag before the template lock code, and your resulting pages will appear in standards mode on IE (all things being normal).

Cheers.

Irruption answered 9/6, 2011 at 15:55 Comment(3)
Why did you put an 'if IE' comment with a </div> AND a '!IE' comment with a </div> at the end? Surely these can be replaced with simply </div>....Chaparral
@Chaparral You're right. It's been a while I did this, I must have been trying to do something else because that double-positive conditional looks like it was written by Homer Simpson. I've edited the code. Cheers.Irruption
Lol @ the Homer Simpson comment.. :)Chaparral
H
2

Dreamweaver (incl. CS6) places the <!-- InstanceBegin template="... comment in front of the doctype tag only if it is unable to locate the opening <html> tag in your template! This happens when you forgot that tag altogether, but also when that tag is placed within conditional comments like this:

<!--[if IE 8]> <html class="ie8"> <![endif]-->

To avoid this you have to refrain from enclosing the <html> tag within conditional comments. When you use a normal undisguised <html> tag in your template code, Dreamweaver will automatically place the <!-- InstanceBegin template="... after that <html> tag in all files derived from that template and IE will not fall into quirks mode.

Homograph answered 8/2, 2013 at 11:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.