Is there a way to create your own html tag in HTML5?

后端 未结 18 1595
情歌与酒
情歌与酒 2020-11-22 07:39

I want to create something like


    
        aaa
        bbb
    
          


        
18条回答
  •  一向
    一向 (楼主)
    2020-11-22 08:17

    You can use custom tags in browsers, although they won’t be HTML5 (see Are custom elements valid HTML5? and the HTML5 spec).

    Let's assume you want to use a custom tag element called . Here's what you should do...

    STEP 1

    Normalize its attributes in your CSS Stylesheet (think css reset) - Example:

     stack{display:block;margin:0;padding:0;border:0; ... }
    

    STEP 2

    To get it to work in old versions of Internet Explorer, you need to append this script to the head (Important if you need it to work in older versions of IE!):

     
    

    Then you can use your custom tag freely.

    Overflow
    

    Feel free to set attributes as well...

     hello 
    

提交回复
热议问题