问题
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