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

后端 未结 5 2129
忘掉有多难
忘掉有多难 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 16:13

    The main advantage I can see with encoding characters is that they'll look right, even if the page is interpreted as ASCII.

    For example, if your page is just a raw HTML file, the default settings on some servers would be to serve it as text/html; charset=ISO-8859-1 (the default in HTTP 1.1). Even if you set the meta tag for content-type, the HTTP header has higher priority.

    Whether this matters depends on how likely the page is to be served by a misconfigured server.

提交回复
热议问题