简体   繁体   English

我应该使用<!DOCTYPE html>在每个文件上?

[英]Should i use <!DOCTYPE html> on every file?

I understand that i should allways use at the begining of my project webpage.我知道我应该始终在我的项目网页的开头使用。

Is this true ONLY for the main page (index) or every html and php file must have it also?这是否仅适用于主页(索引)或每个 html 和 php 文件也必须具有它?

You should use it on every html page just like mrlew said.你应该像mrlew所说的那样在每个html页面上使用它。 This tells the browser what version on html you are using.这会告诉浏览器您使用的 html 版本。 Some strict browser can misplace some stuff and disable some other features if this line is not recongnisez.如果这一行没有被识别,一些严格的浏览器可能会放错一些东西并禁用一些其他功能。

So let say you only put this on your index file, if the user go to another page /streamvideo and you didn't put this line, the html5 video player might just not work.所以假设你只把它放在你的索引文件中,如果用户转到另一个页面 /streamvideo 而你没有放置这一行,那么 html5 视频播放器可能无法工作。

This being said, most common browser will 'fix' stuff like this or 'assume' you're using html5.话虽如此,大多数常见的浏览器都会“修复”这样的东西,或者“假设”您使用的是 html5。

see http://www.html-5-tutorial.com/doctype.htm https://www.w3.org/QA/2002/04/valid-dtd-list.html (sorry i skipped the w3school link :P)参见http://www.html-5-tutorial.com/doctype.htm https://www.w3.org/QA/2002/04/valid-dtd-list.html (抱歉我跳过了 w3school 链接:P )

Opening these link made me think of another example i can give you.打开这些链接让我想到了另一个我可以给你的例子。 before html5, if you have frames in your web page, it would be accurate to use the frame set decralation.在 html5 之前,如果您的网页中有框架,则使用框架集声明是准确的。

Nice example in the w3org link above.上面 w3org 链接中的好例子。 hope this clear things out.希望这清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该为我的Web应用程序使用什么DocType? - What DocType should I use for my webapp? 我需要在带有html的php文件中使用!DOCTYPE声明吗? - Do I need a !DOCTYPE declaration in a php file with html? 将Doctype添加到头文件的顶部是否足够,还是需要将其放置在每个html文件的顶部? - Is Adding the Doctype at the top of the header file enough or does it need to be on top of every html file? 在用于AJAX的PHP文件中是否需要doctype和其他HTML标记? - Do I need doctype and other HTML tag in the PHP file that used for AJAX? 我可以使用 PHP 文件来包含 HTML 数据吗? 还是我应该把它们分开? - Can i use PHP file to contain HTML data. Or should i seperated them? 我应该使用DomDocument解析html代码吗 - Should I use DomDocument for parsing html code 我应该使用$ _GET动态加载html吗? - Should I use $_GET to dynamically load html? 我应该使用AJAX还是事先获取所有数据 - Should I use AJAX or get every data beforehand PHP 5.3命名空间我应该使用带有反斜杠的每个PHP函数吗? - PHP 5.3 Namespaces should i use every PHP function with backslash? 我应该在Laravel 5.2以后的composer.json文件中使用“ laravelcollective / html”:“ 5.2。”而不是“ illuminate / html”吗? - Should I use “laravelcollective/html”: “5.2.” instead of “illuminate/html” in my composer.json file going forward with Laravel 5.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM