HTML 5 是否需要`<html xmlns="http://www.w3.org/1999/xhtml">`

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14563846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:18:09  来源:igfitidea点击:

Does HTML 5 need `<html xmlns="http://www.w3.org/1999/xhtml">`

html

提问by user1830984

When writing a html 5 doctype, do you suppose to include the <html xmlns="http://www.w3.org/1999/xhtml">as you did when previously using HTML4 doctype or should a different xhtml be used?

在编写 html 5 doctype 时,您<html xmlns="http://www.w3.org/1999/xhtml">是否想像以前使用 HTML4 doctype 时那样包含 ,还是应该使用不同的 xhtml?

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml">

采纳答案by mohammad mohsenipur

No, you don't need to include it. This should be enough.

不,您不需要包含它。这应该足够了。

 <!doctype html>
 <html> 

回答by BoltClock

HTML5 does not require the use of the xmlnsattribute as that is specific to XHTML (which means not even HTML 4 uses it either).

HTML5 不需要使用该xmlns属性,因为它是 XHTML 特有的(这意味着即使 HTML 4 也不使用它)。

If you're just serving regular HTML5, then you can leave out that attribute entirely:

如果您只是提供常规 HTML5,那么您可以完全省略该属性:

<!DOCTYPE html>
<html>

The xmlnsattribute is only required if you're writing and serving XML-serialized HTML5, aka XHTML5.

xmlns仅当您编写和提供 XML 序列化的 HTML5,即 XHTML5 时,才需要该属性。

回答by SDC

No you don't. In fact, if you include it, then it isn't HTML5, it's xhtml.

不,你没有。实际上,如果包含它,那么它就不是 HTML5,而是 xhtml。

The xmlnspart is an XML namespace reference. HTML5 is not XML.

xmlns部分是一个 XML 命名空间引用。HTML5 不是 XML。

In fact, if you were using that xmlnspreviously, then you weren't using HTML4 either, you were using xhtml. They're not the same.

事实上,如果您以前使用xmlns过它,那么您也不是在使用 HTML4,而是在使用 xhtml。他们不一样。