HTML5: which is better - using a character entity vs using a character directly?

后端 未结 5 2178
忘掉有多难
忘掉有多难 2021-02-01 15:42

I\'ve recently noticed a lot of high profile sites using characters directly in their source, eg:

“Hi there”

Rather than:

5条回答
  •  渐次进展
    2021-02-01 15:57

    If the encoding is UTF-8, the normal characters will work fine, and there is no reason not to use them. Browsers that don't support UTF-8 will have lots of other issues while displaying a modern webpage, so don't worry about that.

    So it is easier and more readable to use the characters and I would prefer to do so.

    It also saves a couple of bytes which is good, although there is much more to gain by using compression and minification.

提交回复
热议问题