如果我不输入<!DOCTYPE html>会怎样?在我的代码中?会发生重大变化吗? [英] What happens if I don't put a <!DOCTYPE html> in my code? Will it make any major changes?

查看:96
本文介绍了如果我不输入<!DOCTYPE html>会怎样?在我的代码中?会发生重大变化吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HTML处理多个项目,有时我忘了放<!DOCTYPE html>

解决方案

<!DOCTYPE>

<!DOCTYPE> 声明不是HTML标记;

很多IDE允许用户将其忽略,并默认使用特定的HTML。样式,但将其保留下来确实会对浏览器兼容性和旧版HTML的使用造成潜在威胁。



例如:新功能& HTML5中的标记,例如< article> <页脚> < header> &n; nav> ,<$ c如果未声明<!DOCTYPE> ,则可能不支持$ c>< section>



此外,浏览器可能会决定自动进入怪癖或严格模式。


I'm working on several projects with HTML, and sometimes I forget to put <!DOCTYPE html>. Will it make any big or noticeable changes?

解决方案

The <!DOCTYPE> declaration must be the very first thing in your HTML document, before the tag.

The <!DOCTYPE> declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.

A lot of IDEs allow users to leave this out and default to a certain HTML style, but leaving it out does pose a potential threat in browser compatibility and the use of older versions of HTML.

For example: new features & tags in HTML5 such as <article>,< footer >, <header>,<nav>, <section> may not be supported if the <!DOCTYPE> is not declared.

Additionally, the browser may decide to automatically go into Quirks or Strict Mode.

这篇关于如果我不输入&lt;!DOCTYPE html&gt;会怎样?在我的代码中?会发生重大变化吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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