简体   繁体   中英

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?

You should use it on every html page just like mrlew said. This tells the browser what version on html you are using. 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.

This being said, most common browser will 'fix' stuff like this or 'assume' you're using 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)

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.

Nice example in the w3org link above. hope this clear things out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM