它允许在HTML文档中有一个自闭合的div标签吗? [英] Is it allowed to have a self-closing div tag in an html document?

查看:222
本文介绍了它允许在HTML文档中有一个自闭合的div标签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题专指脚本标记。我认为它也适用于一个div,但我只是想确定。这是合法的HTML吗?



< div />

div class =h2_lin>解决方案

不是合法的HTML。 div 元素在 EMPTY 元素。 HTMLrel =noreferrer> DTD (4.01)。



定义中没有 EMPTY

 <!ELEMENT DIV  -   - (%flow;)*  - 通用语言/样式容器 - > ; 
<!ATTLIST DIV
%attrs; - %coreattrs,%i18n,%events -
%保留; - 保留以备将来使用 -
>

HR 的定义相比:

 <!ELEMENT HR  -  O EMPTY  - 横向规则 - > 
<!ATTLIST HR
%attrs; - %coreattrs,%i18n,%events -
>


This question refers specifically to a script tag. I think it applies also to a div, but I just want to make sure. Is this legal html or not?

<div/>

解决方案

No it isn't legal HTML.

The div element is not described as an EMPTY element in the DTD (4.01).

The definition doesn't have EMPTY:

<!ELEMENT DIV - - (%flow;)*            -- generic language/style container -->
<!ATTLIST DIV
  %attrs;                              -- %coreattrs, %i18n, %events --
  %reserved;                           -- reserved for possible future use --
  >

Contrast with the definition for HR:

<!ELEMENT HR - O EMPTY -- horizontal rule -->
<!ATTLIST HR
  %attrs;                              -- %coreattrs, %i18n, %events --
  >

这篇关于它允许在HTML文档中有一个自闭合的div标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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