Why is “®” being rendered as “®” without the bounding semicolon

前端 未结 8 443
孤街浪徒
孤街浪徒 2020-11-30 06:14

I\'ve been running into a problem that was revealed through our Google adwords-driven marketing campaign. One of the standard parameters used is \"region\". When a user se

8条回答
  •  悲哀的现实
    2020-11-30 07:10

    Although valid character references always have a semicolon at the end, some invalid named character references without a semicolon are, for backward compatibility reasons, recognised by modern browsers' HTML parsers.

    Either you know what that entire list is, or you follow the HTML5 rules for when & is valid without being escaped (e,g, when followed by a space) or otherwise always escape & as & whenever in doubt.

    For reference, the full list of named character references that are recognised without a semicolon is:

    AElig, AMP, Aacute, Acirc, Agrave, Aring, Atilde, Auml, COPY, Ccedil, ETH, Eacute, Ecirc, Egrave, Euml, GT, Iacute, Icirc, Igrave, Iuml, LT, Ntilde, Oacute, Ocirc, Ograve, Oslash, Otilde, Ouml, QUOT, REG, THORN, Uacute, Ucirc, Ugrave, Uuml, Yacute, aacute, acirc, acute, aelig, agrave, amp, aring, atilde, auml, brvbar, ccedil, cedil, cent, copy, curren, deg, divide, eacute, ecirc, egrave, eth, euml, frac12, frac14, frac34, gt, iacute, icirc, iexcl, igrave, iquest, iuml, laquo, lt, macr, micro, middot, nbsp, not, ntilde, oacute, ocirc, ograve, ordf, ordm, oslash, otilde, ouml, para, plusmn, pound, quot, raquo, reg, sect, shy, sup1, sup2, sup3, szlig, thorn, times, uacute, ucirc, ugrave, uml, uuml, yacute, yen, yuml

    However, it should be noted that only when in an attribute value, named character references in the above list are not processed as such by conforming HTML5 parsers if the next character is a = or a alphanumeric ASCII character.

    For the full list of named character references with or without ending semicolons, see here

提交回复
热议问题