什么是DOCTYPE? [英] What is DOCTYPE?

查看:83
本文介绍了什么是DOCTYPE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 什么是DOCTYPE,我为什么要使用它?

  • 我可以使用哪些不同的DOCTYPE?

  • 标准和怪癖模式有什么区别,以及我可能遇到的不同设置的DOCTYPE有哪些怪癖?


    最后,我应该使用什么样的DOCTYPE?

    解决方案

    基本上,DOCTYPE描述了将用于您的页面。



    浏览器还使用DOCTYPE来确定如何呈现页面。不包括DOCTYPE或包含不正确的DOCTYPE可能会触发怪癖模式。这里的问题在于,Internet Explorer中的怪癖模式与Firefox(以及其他浏览器)中的怪癖模式有很大不同,这意味着您要努力确保您的网页始终如一地运行如果页面以怪癖模式呈现,那么它们的浏览器比以标准模式呈现时的浏览器为准。



    维基百科有更深入的在使用各种DOCTYPE时呈现的差异。 XHTML是由某些doctypes启用的,关于使用XHTML的争论有相当多的争论,这在 XHTML - 神话与现实
    $ b 不同的标准投诉呈现文档类型之间存在细微差异,例如HTML5文档类型(<$在HTML5之前,只有被称为skinny doctype的文件不会触发旧版浏览器中的标准化渲染)以及其他DOCTYPE,例如这个用于HTML 4.01过渡版的DOCTYPE:c $ c><!DOCTYPE html>

     <!DOCTYPE HTML PUBLIC -  // W3C // DTD HTML 4.01 Transitional // ENhttp:// www.w3.org/TR/html4/loose.dtd\"> 


    • What is DOCTYPE and why do I want to use it?
    • What are the different DOCTYPEs I can use?
    • What is the difference between standards and quirks mode, and what are some quirks I may run into with differently set DOCTYPEs?

    Lastly, what is the proper DOCTYPE that I should be using?

    解决方案

    Basically, the DOCTYPE describes the HTML that will be used in your page.

    Browsers also use the DOCTYPE to determine how to render a page. Not including a DOCTYPE or including an incorrect DOCTYPE can trigger quirks mode. The kicker here is that quirks mode in Internet Explorer is quite different from quirks mode in Firefox (and other browsers), meaning that you'll have a much harder job trying to ensure your page works consistently in all browsers if pages are rendered in quirks mode than you will if they are rendered in standards mode.

    Wikipedia has a more indepth summary of the differences in rendering when using various DOCTYPEs. XHTML is enabled by certain doctypes, and there is quite a bit of debate about the use of XHTML which is covered well in XHTML — myths and reality.

    There are subtle differences between different "standards complaint" rendering doctypes, such as the HTML5 doctype (<!DOCTYPE html>, prior to HTML5 only known as the "skinny doctype" which not trigger standardised rendering in older browsers) and other DOCTYPEs such as this one for HTML 4.01 transitional:

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

    这篇关于什么是DOCTYPE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆