I'm using the great HTML5 boilerplate. It's a great project but I'm having some big issues rendering in IE 8 and 7 (possibly 8 but haven't tried yet)
The files have the HTML5 doctype:
<!doctype html>
<head>
But the problem is that having no full and ugly doctype like...
<!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">
I get all kind of rendering issues: centering by margin:auto doesn't work, heights, widths, martings and paddings all behave like crazy and all my layout is broken with just <!doctype>
but if I switch to the old one, everything works great (well, not great, it's still IE, but as expected)
HTML5 Boilerplate comes with Modernizer which I think should fix this but it's not working. From my "research" (Google) I found that IE enters in quirks mode width <!doctype>
, so the question is...
Is there a way to prevent IE going into quirks mode with <!doctype>
?
Or at least not to break margins, widths, paddings, etc?
Edit: This is the full head:
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
The absence of the DOCTYPE or its incorrect usage will force the browser to switch to quirks mode. It means that the browser will do its best to layout the page that is considered to be old or created against web standards.
All HTML need to have a DOCTYPE declared. The DOCTYPE is not actually an element or HTML tag. It lets the browser know how the document should be interpreted, by indicating what version or standard of HTML (or other markup language) is being used.
doctype html> or <! This is because, html5 is a SGML based, unlike HTML4. 01 or XHTML1. As soon a browser finds <! doctype html> in the starting of an HTML document, it represents the document in standard mode.
When a Web browser encounters a DOCTYPE tag, it processes the page in standards mode. When it doesn't encounter the DOCTYPE tag, it assumes that there is something quirky about the page, and processes the page in quirks mode.
IE doesn't go into quirks with the HTML doctype - that's the whole point!
What's nice about this new DOCTYPE, especially, is that all current browsers (IE, FF, Opera, Safari) will look at it and switch the content into standards mode - even though they don't implement HTML5. This means that you could start writing your web pages using HTML5 today and have them last for a very, very, long time.
(http://ejohn.org/blog/html5-doctype/)
However, having anything before the doctype (newlines, comments etc) will.
I'd check what you are doing - the HTML5 doctype will not put your browser into quirks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With