Why does Firefox display empty elements with closing tags in its web inspector?

时间:2015-06-15 14:20:18

标签: html xml html5 firefox

As HTML5 is not an XML-based language, we can forget the self closing tags. That's great. So when I want to insert a new horizontal line, I just write <hr> and not <hr />.

But when I inspect the <hr> element in Firefox, it renders as <hr></hr>. It does not happen in any other browser.

Why does this happen? Is this some compatibility issue with Firefox?

2 个答案:

答案 0 :(得分:1)

这只是Firefox浏览器的一种古怪行为。

编辑:对不起,但由于我的SO声誉,我无法直接评论。

答案 1 :(得分:1)

自闭标签可能很危险,因为它们有一些特定于浏览器的行为,因此编写较长的表单总是更好。似乎Firefox实际上是试图通过扩展来帮助你,所以你不会遇到一些问题。

例如,在这种情况下,您可能会遇到使用它们的JS框架的问题:

https://github.com/angular/angular.js/issues/1953