如何创建自闭式HTML5标签(如< br> [英] How to create a self-closing HTML5 tag like <br>

查看:50
本文介绍了如何创建自闭式HTML5标签(如< br>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想基本上制作一个不需要关闭的自定义标签,然后将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/>.

推荐答案

除非已将元素定义为

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;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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