问题描述
我想基本上制作一个不需要关闭的自定义标签,然后将css应用于该标签.
I want to basically make a custom tag that doesn't need to be closed and apply css to it.
看起来不应该是这样的:< customtag></customtag>
.
It shouldn't look like this:<customtag></customtag>
.
它应该看起来像这样:< customtag>
或< customtag/>
.
It should look like this: <customtag>
or <customtag/>
.
推荐答案
除非已将元素定义为 void元素,它们必须具有结束标记.
Unless an element is already defined to be a void element in the HTML spec, they must have a closing tag.
因此,所有自定义Web组件都必须具有关闭标签.此外,自定义元素的名称中必须带有连字符,以避免与可能的字符产生冲突.将来的标签.
Because of this, all custom web components must have a close tag. Additionally, custom elements must have a hyphen in their names to avoid conflicting with possible future tags.
这篇关于如何创建自动关闭的HTML5标签,如& lt; br& gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!