Skip to main content
HTML Validation

Bad value X for attribute “href” on element “a”: Illegal character in path segment. “<” is not allowed.

About This HTML Issue

The href value on the <a> element contains a literal < character, which is not allowed in a URL path.

The URL standard does not allow a raw < anywhere in a URL. Escaping it as &lt; does not help, because the HTML parser turns &lt; back into < before the URL is read. If a path really needs the character, write it as %3C.

A value that starts with part of a tag, such as <div class=, means a template or content filter wrote HTML where a URL belongs. Lazy-loading and video embed plugins can do this when they swap a video URL for placeholder markup without checking whether the URL sits inside an attribute. The first " in that markup closes the href, so the value stops at class= and the browser treats it as a relative path to a page that doesn't exist.

The rest of the injected tag spills into the <a> start tag as broken attributes. That's why the validator usually also reports a stray end tag and a quote in an attribute name for the same link. Those errors go away once the href holds a plain URL.

Other values with a < come from angle brackets copied along with an address, as in <https://www.example.com/> from a plain-text email, or from placeholders like /files/<name>.pdf left in a template. Remove the brackets or fill in the real value.

Invalid example

<a href="<div class="video-embed" data-src="https://www.example.com/embed/abc123"></div>">Watch the video</a>

Valid example

<a href="https://www.example.com/embed/abc123">Watch the video</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