I have a page which needs to be rendered in Quirks mode for the page to be loaded properly. The problem is that the page uses valid XHTML and thus has a doctype. This forces the page to render in Standards mode in all browsers. Is there any workaround/hack that can force Quirks mode eventhough I have a doctype?
I also have a page that must live in the 90s along with all the memory leaks that come with IE in quirks mode, this is the DOCTYPE we use.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
See http://hsivonen.iki.fi/doctype/ for changing the DOCTYPE to Almost Standards mode or Quirks mode. Excerpts below. (Assumes a Content-Type of text/html.)
Almost Standards mode:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
This gives you the Almost Standards mode. Please note that your
layouts based on sliced images in tables are likely to break if you
later move to HTML5 (and, hence, the full Standards mode), so it’s
better to make your designs Standards mode-compatible right now.
Quirks mode:
No doctype.
Please don’t do this. Willfully designing for the Quirks mode will
come and haunt you, your coworkers or your successors in the future.
XHTML doctype:
I am not recommending any of the XHTML doctypes, because serving XHTML
as text/html is considered harmful. If you choose to use an XHTML
doctype anyway, please note that the XML declaration makes IE 6 (but
not IE 7!) trigger the Quirks mode.
Try removing the doctype?
Related
No matter what I try to do, pages keep looking significantly different depending on whether they are from my local machine or the development server. When pressing F12, I've finaly noticed that pages have different instructions on the top:
1) Pages displayed by my local machine have the following values:
Browser Mode: IE9 Compatible View
Document Mode: Quirks
HTML starts with this line of code
<html xmlns="http://www.w3.org/1999/xhtml">
2) Whereas pages displayed by the development server have the following values:
Browser Mode: IE9 Compatible View
Document Mode: IE7 Standards
HTML starts with this line of code
<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" -->
<html xmlns="http://www.w3.org/1999/xhtml">
It looks like the the first line of the instruction that's making those pages to display differently.
Do I need to add that line to pages coming from my local machines as well? Why and how to do that?
Thanks for helping
Without a doctype, you are in quirks mode, and, no matter what else you do, pages won't look the same as in strict mode.
New web pages should always have a doctype and always use strict. Rarely would a newly created page have a need for quirks or the transitional doctype you are using.
Add either that transitional doctype on your first line or, preferably, the strict version:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
Better yet, use the new type: <!DOCTYPE html> which will keep all browsers in strict mode, including IE back to IE6 (or even IE4? Don't recall).
I've noticed some weird behavior with a CMS i'm using. The Doctype is commented out in Internet Explorer 7 (IE9 in IE7 standards mode) see attached image:
I think this is causing a few other errors i have with CSS and JavaScript (jQuery).
Does anyone know anything that will trigger this behavior.
The doctype i'm using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Once the DOCTYPE has determined whether to use quirks (like IE5.5) mode or slightly-more-standards (IE7 native) mode, the DOCTYPE is not really of interest to the browser any further.
It seems that IE7 (at least) then inserts the doctype into the DOM as if it was a comment.
It's just the way the browser works. Unless you've JavaScript walking the DOM, it's unlikely to affect the way the page works.
I was in a hurry to churn out some html code and did not provide a DTD tag for my index.htm file...does anyone know what DTD is used by default when no tag is provided?
The reason I ask is that when I add in my chosen type of
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
the page is distorted and I want to go in and fix it. My code follows the guide lines given for XHTML at
Thanks!
Browsers don't "fake" a doctype they parse in "quirks mode". Quirks mode assumes the web page was written a while ago and never updated, so it attempts to render it in the same way an older version of the browser would have in order to attain backwards compatibility.
In Internet Explorer, rendering in quirks mode makes the page appear the same as it would have in IE 5.5.
I'm not a front-end programmer, but I first realized the issue just when I found the css.maxHeight is not supported by HTML4.0. when the DOCTYPE refers to HTML4.0, maxHeight in css doesn't work, but change the DOCTYPE to XHTML1.0, it works.
So, now have the question, What the difference between the support for css by HTML4.0 and XHTML1.0? or, where can I get the comparison chart or statistic?
Edit:
-- sorry for the mistype, it's maxHeight not maxLength--
what the css.maxHeight i mean is just by the simple code as below, the backgroundColor works in HTML4.0 but maxLength no.
<script languague="javascript" type="text/javascript">
$(document).ready(function() {
var div = $("div");
div.css({ maxHeight: 200,
overflow: 'auto',
backgroundColor:'#eee'
});
});
</script>
and here is the two type of DOCTYPE references
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Using different versions of HTML doesn't really have anything to do with the support for CSS. The different versions of CSS is independent of the versions of HTML.
What can matter is if the page renders in standards compliant mode or quirks mode. If you don't have a proper doctype tag, the browser thinks that it's an old page before the era of standardisation and reverts to quirks mode where it tries to be backwards compatible with ancient versions of browsers.
The sets of features that the browser supports are different for standards compliant mode and quirks mode, mostly it's non-standard features that are disabled in standards compliant mode.
I'm not sure what you mean by "css.maxLength" as there is no maxlength property in CSS. There is a maxlength attribute in HTML for textboxes, and that is supported in all versions of HTML.
There is (or at least should) be no difference. CSS is independent of (X)HTML. You can use HTML 4 with CSS 3 if the browser supports CSS 3 features. XHTML 1.0 is basically HTML 4 in XML syntax with some presentation related tags and attributes deprecated.
Having said that. If you see differences between those pages then you're probably seeing the browser switching between quirks and standards compliant mode. You said you just changed the DOCTYPE from HTML 4 to XHTML. Did you also rewrite the rest of the document to be XML compliant for XHTML too?
Do we use doctype only to render webpages in standard mode with IE6 ? or does doctype do something more than that?
The doctype actually tells ALL browsers the type of content in the page. In many browsers, you'll notice very little difference, but in IE it has two different rendering modes, so you'll see a larger difference.
You should be using a doctype on all of your HTML documents. The idea is that it will be a much simpler doctype in the future - HTML 5 looks like this:
<!DOCTYPE html>
Whereas HTML 4 is like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
And has Transitional or Strict options.
It's not just IE6, it tells all browsers how to attempt to render the page.
Good information here and here.
Doctype could also used to check that your page respects the W3C standard.