Doctype html - 在它后面需要一个 html 标签吗? [英] Doctype html - do you need an html tag after it?

查看:30
本文介绍了Doctype html - 在它后面需要一个 html 标签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你设置了页面

<!DOCTYPE html>

你需要像

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

之后呢?

伙计们干杯.

推荐答案

在除 XHTML 版本之外的任何 HTML 版本中, 标记是不需要的,因此没有任何作用.但是,该标签对于指定整个文档内容的主要语言很有用,例如.

In any HTML version other than XHTML versions, the <html> tag is not needed and does not have any effect as such. However, the tag is useful for specifying the main language of the content of the entire document, e.g. <html lang="en">.

在 XHTML 中,标记始终是必需的,并且必须具有 xmlns 属性,如示例中所示.(它可能还具有其他属性.)该标记是必需的,因为 html 元素存在于任何 XHTML 文档中,并且 XHTML 不允许省略开始标记.该属性是必需的,因为特定的 XHTML 规则是这样说的.

In XHTML, the tag is always required and must have the xmlns attribute as in the example. (It may additionally have other attributes.) The tag is required, because the html element is present in any XHTML document, and XHTML never allows start tag omission. The attribute is required because a specific XHTML rule says so.

这与文档类型问题无关.使用 <!DOCTYPE html> 现在很常见,通常被视为HTML5 doctype".以上仍然适用,因为 HTML5 有两种替代语法,HTML 语法和 XHTML 语法.

This has nothing to do with the doctype issue. Using <!DOCTYPE html> is nowadays common and often seen as "the HTML5 doctype". The above still applies, since HTML5 has two alternative syntaxes, the HTML syntax and the XHTML syntax.

这篇关于Doctype html - 在它后面需要一个 html 标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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