Making Custom HTML Tags

耗尽温柔 提交于 2021-01-29 02:28:35

问题


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

Can you make it once and then just use it over and over again in the same file without redefining it? Can you import it into other files?

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.


回答1:


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.



来源:https://stackoverflow.com/questions/7451196/making-custom-html-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!