标准模式(standard mode) 和 兼容模式(qurik mode)
qurik mode
- 兼容模式(qurik mode),别称混杂模式、怪异模式,当 html 文档没有定义
<!DOCTYPE>
或者定义错误不能识别时, html 文档会变为兼容模式 - 页面以较宽松的向后兼容的形式呈现,以兼容各个浏览器
standard mode
- 标准模式(standard mode),别称严格模式
- 排版以及js运行模式以浏览器所支持的最高标准运行
主要区别
盒模型
- qurik
在 IE5
和 IE6
的兼容模式中,盒模型使用 IE盒模型 的标准呈现,即 width(盒子实际宽度) = width (包含 width + padding-left + padding-right + border-left + border-right)
- standard
盒模型使用 w3c盒模型 的标准呈现,即 width(盒子实际宽度) = width + padding-left + padding-right + border-left + border-right
行内元素设置宽高
- qurik
在 IE5
和 IE6
的兼容模式中,行内元素可以使用 CSS 来设置宽高
- standard
行内元素不能使用 CSS 来设置宽高
判断标准模式和兼容模式
//BackCompat 表示怪异模式
//CSS1Compat 表示标准模式
console.log(window.top.document.compatMode) ;