Can data-* attribute contain HTML tags?

前端 未结 4 1877
情书的邮戳
情书的邮戳 2020-12-05 18:26

I.E. What gives?\"/>

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 18:58

    Providing you're serving it as text/html, then yes it's valid.

    Note that not only is it possible to include markup inside attributes, but the HTML5 srcdoc attribute on the iframe element positively encourages it. The HTML5 draft says:

    In the HTML syntax, authors need only remember to use U+0022 QUOTATION MARK characters (") to wrap the attribute contents and then to escape all U+0022 QUOTATION MARK (") and U+0026 AMPERSAND (&) characters, ....

    Note, that when served with an XML content type (e.g. application/xhtml+xml), it is not valid, or even well-formed.

提交回复
热议问题