Re: [EXT] Legal characters in id name

Philip Taylor (P.Taylor@rhul.ac.uk) wrote:

> The href attribute on a
> <https://www.w3.org/TR/html52/single-page.html#elementdef-a> and area
> <https://www.w3.org/TR/html52/single-page.html#elementdef-area> elements
> must have a value that is a valid URL potentially surrounded by spaces
> <https://www.w3.org/TR/html52/single-page.html#valid-url-potentially-surrounded-by-spaces>
> .
>
> This indeed is the point. The brackets [ ] are allowed in an id attribute
value, but not in the URL syntax, hence not in an href attribute value,
without % encoding.

However, the relevant specification is not RFC 3986 (also known as STD 66),
since HTML specifications refer to the “Living Standard” for URL syntax,
specifically (for this type of URL)  the part that defines “valid URL
string” there:
https://url.spec.whatwg.org/#valid-url-string
It explicitly lists the characters allowed; anything else must be percent
encoded. And since the brackets are not listed, you need to write

href="#%5B-123-%5D"

Received on Saturday, 27 February 2021 15:37:51 UTC