Skip to main content
HTML Validation

Bad value X for attribute “href” on element “a”: Illegal character in fragment. “[” is not allowed.

About This HTML Issue

A [ in the fragment of a link's URL, the part after #, has to be percent-encoded as %5B.

The URL Standard only allows square brackets around an IPv6 address in the host, as in http://[::1]/. Anywhere else, including the fragment, a valid URL writes [ as %5B and ] as %5D. Browsers still follow a link with raw brackets, but the href value isn't a valid URL, and the validator reports the first [ it finds.

This often comes from long links copied out of a browser's address bar, such as map or search pages that keep coordinates or filters after the #. When the URL is that long (around 200 characters or more), the validator leaves it out of the message, which then reads Bad value for attribute "href" with no value at all. To find the link, look for an href with a [ after its #.

Encoding the brackets doesn't break links to elements on the same page. Browsers percent-decode the fragment when they look for a matching id, so href="#step%5B2%5D" still scrolls to id="step[2]". For a link to another site, open the encoded URL once to check that the target page still reads its fragment correctly.

Invalid example

<a href="https://example.com/map#view:[40.64,-8.63]">Open the map</a>

Valid example

<a href="https://example.com/map#view:%5B40.64,-8.63%5D">Open the map</a>

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries