I forgot to post this: [Wayback/Archive] Which characters need to be escaped in HTML? – Stack Overflow
If you’re inserting text content in your document in a location where text content is expected1, you typically only need to escape the same characters as you would in XML. Inside of an element, this just includes the entity escape ampersand&and the element delimiter less-than and greater-than signs<>:& becomes & < becomes < > becomes >
I didn’t quote further, as this bit is somehow important for WordPress posts. WordPress reminded me the hard way when initially these posts were wrongly titled:
- What is the difference between
<p>,<div>and<span>in HTML&XHTML? (wrongly titled “What is the difference between , and in HTML&XHTML?“)- The text of the Title needed to be escaped into
Another difference between the <p> and <div> element in HTML&XHTML
- The text of the Title needed to be escaped into
- Another difference between the
<p>and<div>element in HTML&XHTML (wrongly titled “Another difference between the and element in HTML&XHTML“)- The text of the title neede to be escaped into
Another difference between the <p> and <div> element in HTML&XHTML
- The text of the title neede to be escaped into
Warning:
It also means the “Press This” bookmarklet always gets unescaped plain text wrong. Watch this when selecting text for blogging and check if the selected text actually got into your post fine.
Thanks [Wayback/Archive] Ahmet for asking the above question and [Wayback/Archive] Jeremy for answering it.
–jeroen






