On Dec 1, 2017 18:56, "Liam R. E. Quin" <liam@w3.org> wrote:
On Fri, 2017-12-01 at 17:23 -0800, Tab Atkins Jr. wrote:
>
[...]
> Right. All you need, to be precise, is:
>
> 1. In text, escape & and <.
> 2. In a quoted attribute value, escape & and whatever character you
> use for quoting (either ' or "). (Unquoted attribute values have more
> complex rules, only use them if you have simple values.)
Pedantic addition - escape > when it appears in the plain text outside
a CDATA section but in the sequence ]]> - i haven't checked whether
this is still true for HTML 5, though, and Web browsers probably don't
care; it's an error "for SGML compatibility" in XML to have ]]> appear
except to mark the end of a CDATA section.
Incorrect handling of CDATA sections, especially in generated markup,
is a rat's nest for another day [1] :)
CDATA doesn't meaningfully exist in the HTML syntax any longer, so that's
not a concern. Insert raw > characters as your heart desires!
~TJ