XHTML5 and HTML4 character entities

前端 未结 5 2081
我寻月下人不归
我寻月下人不归 2020-12-09 11:57

Does XHTML5 support character entities such as   and . At work we can require specific software to access the admin side of the

5条回答
  •  攒了一身酷
    2020-12-09 12:20

    There is no DTD for XHTML5, so an XML parser will see no entity definitions (other than the predefined ones). If you wanted to use an entity you would have to define it for yourself in the internal subset.

    
    ]>
    
        ... — ...
    
    

    (Of course using the internal subset is likely to trip browsers up if you serve it to them as text/html. Sending an internal subset in a non-XHTML HTML5 document is disallowed.)

    The HTML5 wiki currently recommends:

    Do not use entity references in XHTML (except for the 5 predefined entities: &, <, >, " and ')

    And I agree with this advice not just for XHTML5 but for XML and HTML in general. There's little reason to be using the HTML entities for anything today. Unicode characters typed directly are far more readable for everyone, and &#...; character references are available for those sad cases when you can't guarantee a 8-bit/encoding-clean transport. (Since HTML entities are not defined for the majority of Unicode characters, you are going to need those anyway.)

提交回复
热议问题