2

An article in the Wall Street Journal (wsj.com) displays HTML special character code instead of the actual character, the greater-than sign. Thus, instead of displaying >, the article displays >. This occurs (for me, at least) on Chrome, Firefox, and Safari (all latest versions with cache cleared).

My (limited) understanding is that websites should have the following code in the header:

<meta http-equiv="content-type" content="text/html;charset=utf-8" /> [α]

The wsj.com site has this code in the header: <meta charset="UTF-8">. Is this the cause of the problem? In other words, if the WSJ site had <meta http-equiv="content-type" content="text/html;charset=utf-8" /> in the header, would we see > instead of &gt;?

The Wall Street Journal article is:

The article is probably behind a firewall, so here is an image of the sentence as it appears in the article:

sentence in WSJ article displaying HTML special character code

TIA,

Mark

Footnote
α. Kyrnin, Jennifer. "How to Use Special Characters in HTML." Lifewire (20 February 2020).

  • The Wall Street Journal sort of corrected the article about one hour after I posted my question. I say "sort of" because it now reads "Settings then General then Software Update", as opposed to correcting the HTML problem. – Mark D Worthen PsyD Sep 17 at 4:39
2

Thus, instead of displaying >, the article displays >. This occurs (for me, at least) on Chrome, Firefox, and Safari (all latest versions with cache cleared).

That is probably a software error where > was turned into &gt; then that was turned into &amp;gt; by some kind of duplicate encoding. You can use "Control-U" to view the HTML source code of the page and check it.

The wsj.com site has this code in the header: . Is this the cause of the problem?

No, that is standard now.

https://www.w3schools.com/tags/att_meta_charset.asp

| improve this answer | |
1

There are five characters that should be escaped as entities in HTML documents, no matter which character set your website uses:

  • < as &lt;
  • > as &gt;
  • & as &amp;
  • " as &quot;
  • ' as &#39;

Other special characters always can be escaped with entities, but only need to be if you are using a character set that doesn't contain them. If you are using UTF-8 as your character set, you only need to escape the five characters above and not international characters. Some character sets have a limited set of characters available and require that characters outside the set be escaped with entities. For example if you use ISO-8859-1 you would have to escape the Greek letter Phi as &phi; whereas if you were using UTF-8 you could just include the character for it: Φ.

If you see a &gt; in the text of a web page, that is an indication that it has been escaped twice. If you single escape > it comes out as &gt; in the source code which displays as >. If you double escape it it comes out as &amp;gt; in the source code which displays as &gt;. To fix the problem, the Wall Street Journal would need to fix the number of times they are escaping the text rather than adjust the character set they are using.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.