Why is the site running in IE quirks mode?

六眼飞鱼酱① 提交于 2019-12-18 07:23:19

问题


I've got a site: http://www.sucramma.dk When I'm in FF, Chrome, or Safari, the site is displayed as it should, but in IE the site is left aligned, and is running is quirks mode. Why? The doctype is set!


回答1:


It's a Byte Order Mark, , which is invisible to most text editors. Try using VIM and killing it or somehow find a different text editor and kill everything before <!DOCTYPE html>

You can simply copy <!DOCTYPE HTML> and everything below it into a new file and save over it, meaning you wont be copying the BOM coming before it to resolve this issue; I've ran into it many times.




回答2:


http://validator.w3.org/check?uri=www.sucramma.dk&charset=%28detect+automatically%29&doctype=Inline&group=0

The validation fails, see the first error:

Error Line 1, Column 1: Non-space characters found without seeing a doctype first. Expected .

The doctype is not sufficient to oblige the browser to standard mode. When an error it is encountered the rendering fall back to quirks mode.

Correct the errors and try again, you should be done




回答3:


The site doesn't have a DOCTYPE so it will be running in quirks mode because it doesn't know what DTD to use...

EDIT: As pointed out by BoltClock, it does have a DOCTYPE (I'm just not up to scratch on HTML5 yet). My apologies.

Read more here: http://www.w3schools.com/tags/tag_doctype.asp




回答4:


Try using full doctype declaration (and without a space at the beginning)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">




回答5:


I had this issue I changed to <!DOCTYPE html> and the it fixed it



来源:https://stackoverflow.com/questions/5063789/why-is-the-site-running-in-ie-quirks-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!