如何创建自己的HTML标签? [英] how can i create my own HTML tag?
问题描述
如何在HTML或HTML5中创建自己的html标签,以便可以制作自己的html标签和CSS库 例如
how can i create my own html tags in HTML or HTML5 so i can make my own html tag and css library such as
<mymenu> ul li or some text </mymenu>
<heading> Yeah My Own Heading</heading>
他们是这样做的一种方法吗?如果是的话,请告诉我我对此真的很好奇.并告诉我制作个性化标签后(如果您知道的话)我应该遇到什么问题.
is their a way to do that? if yeah please tell me how i am really curious about it. and tell me what problems should i will be having after making my personalize tags (if you know any) .
推荐答案
做到这一点的正确"方法是使用类:<div class="mymenu">
.话虽如此,我知道的每个浏览器都会很好地显示您的<mymenu>
标记,您可以根据需要设置其样式:
The "proper" way of doing this is to use classes: <div class="mymenu">
. That being said, every browser I know of will display your <mymenu>
tag just fine and you can style it however you want:
mymenu {
display : block;
background : teal;
}
演示: http://jsfiddle.net/cwolves/DPMCM/2/
请注意IE< 9不会立即正确显示此内容.要解决此问题,只需在页面上的任意位置(创建元素之前)使用以下JS:
Note that IE<9 will not immediately display this properly. To get around that, simply use the following JS anywhere on your page (before the elements are created):
document.createElement('mymenu');
,它将告诉IE CSS引擎mymenu
标签存在.
which will tell the IE CSS engine that a mymenu
tag exists.
这篇关于如何创建自己的HTML标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!