Today when I was testing the compatibility of the <main>
tag in HTML5, I had a sudden idea and changed "main" to "abcd",
Then I thought that the browser would ignore the style of <abcd>
, but the result was not the case,
It behaves exactly like a normal tag.
I feel very strange, isn’t that XML?
HTML 把未知标签解析为普通标签是有很多好处的:
对于不支持的标签,可以给出提示:
<video>浏览器不支持</video>
一些新的语义化标签,如
<article></article>
,即便不支持,也能够显示出来用户定义标签,如 Angular、Vue 定义的标签,在 js 文件未加载时,仍可以显示内容
对新标签的包容性更强。你不会希望在使用新标签时,在不支持它的浏览器上完全没效果,还无法给出提示信息。
这样看,应该就布奇怪了吧。
HTML5是支持自定义标签的。