If your attribute value is quoted (starts and ends with double quotes "
), then any characters except for double quotes and ampersands are allowed, which must be quoted as "
and &
respectively (or the equivalent numeric entity references, "
and &
)
You can also use single quotes around an attribute value. If you do this, you may use literal double quotes within the attribute: <span title='This is a "good" title.'>...</span>
. In order to escape single quotes within such an attribute value, you must use the numeric entity reference '
since some browsers don't support the named entity, '
(which was not defined in HTML 4.01).
Furthermore, you can also create attributes with no quotes, but that restricts the set of characters you can have within it much further, disallowing the use of spaces, =
, '
, "
, <
, >
, `
in the attribute.
See the HTML5 spec for more details.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…