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

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

I want to create something like


    
        aaa
        bbb
    
          


        
18条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 08:12

    I'm not so sure about these answers. As I've just read: "CUSTOM TAGS HAVE ALWAYS BEEN ALLOWED IN HTML."

    http://www.crockford.com/html/

    The point here being, that HTML was based on SGML. Unlike XML with its doctypes and schemas, HTML does not become invalid if a browser doesn't know a tag or two. Think of . This has not been in the official standard. So while using it made your HTML page "officially unapproved", it didn't break the page either.

    Then there is , which was Netscape-specific, forgotten in HTML4 and rediscovered and now specified in HTML5. And also we have custom tag attributes now, like data-XyZzz="..." allowed on all HTML5 tags.

    So, while you shouldn't invent a whole custom unspecified markup salad of your own, it's not exactly forbidden to have custom tags in HTML. That is however, unless you want to send it with an +xml Content-Type or embed other XML namespaces, like SVG or MathML. This applies only to SGML-confined HTML.

    提交回复
    热议问题