类似这样

内容为空的标签能否缩写成下面这样呢?

根据xhtml 1.0 的要求 Element Minimization and Empty Element Content不推荐这样写。

Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use

and not

).

另外,可能还会导致浏览器错误。

运行代码 [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

比如这个测试页面服务器伺服成 application/xhtml+xml

这是不完整的标签伺服成 application/xhtml+xml的例子,伺服成 application/xhtml+xml 就会报错,由此知之。

结论:如果伺服成 application/xhtml+xml可以缩写,而伺服成 text/html 就会导致错误。

Using end tag is required.