开发者

& or & what should be used for & (ampersand) if we are using UTF-8 in an XHTML document?

What is the difference开发者_StackOverflow between & and & for & (ampersand)?

What should be used with UTF-8?


Both are character references and refer to the same character (AMPERSAND, U+0026). & is a named or entity character reference and & is a numerical character reference.

In fact, & is actually just a substitution for & (see list of character entities):

<!ENTITY amp     CDATA "&#38;"   -- ampersand, U+0026 ISOnum -->


If you both save your file in UTF-8 and even specify it for strict browsers:

<head><meta charset="utf-8">

I would guess that you can also just use the & character. All new browsers will support it and UTF-8.


Entities: Handling Special Content

According to O'Reilly, you should be using & in XML. UTF-8 is quite a bit different. Unicode Character 'AMPERSAND' (U+0026)


No difference. UTF-8 doesn't matter because & is reserved anyway. So use &amp;.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜