制作自定义HTML标签 [英] Making Custom HTML Tags

查看:65
本文介绍了制作自定义HTML标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解您可以制作自己的HTML标签,但是我该如何做呢?

I understand that you can make your own HTML tags, but how do I go about doing it?

您能否制作一次,然后只在同一个文件中重复使用而无需重新定义它?您可以将其导入其他文件吗?

我还想知道是否建议制作自定义HTML标签.可以在所有浏览器中使用吗?

I also want to know if it is recommended to make custom HTML tags. Does it work in all browsers?

我知道很多,所以我会先谢谢你.

I know this is a lot, so I will thank you in advance.

推荐答案

为什么首先要这样做?通常,人们会坚持使用现有标签,如果需要使其具有唯一性,则可以通过id,类或属性来实现.但是,随着HTML5的引入(其中引入了许多新标签),这个问题浮出水面,因为IE不支持它们.在IE中支持HTML5标签的解决方案是使用 HTML5 shiv .基本上,您会在头部执行以下操作:

Why would you want to do that in the first place? Generally, people stick with existing tags and if they need to make them unique, they do it through ids, classes or attributes. However, with introduction of HTML5, which introduced a number of new tags, this problem surfaced, since IE was not supporting them. The solution for supporting HTML5 tags in IE was using HTML5 shiv. Basically, in the head you do something like that:

document.createElement("article");  
document.createElement("footer");  
document.createElement("header");  
document.createElement("hgroup");  
document.createElement("nav"); 

也许您可以做类似的事情?仍然不确定为什么要这么做.

Perhaps you can do something like that? Still not sure why you'd want to do that though.

这篇关于制作自定义HTML标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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