HTML Guides for path segment
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
The href of an <a> element has a literal space in its URL path, and the URL is too long for the validator to quote in the message.
A valid URL has no literal spaces. In the path (the part after the domain and before any ? or #), a space has to be percent-encoded as %20. Browsers encode the space themselves when someone follows the link, so the link often works, but the href is still not a valid URL.
The validator usually prints the bad value between Bad value and for attribute. When the value is 200 characters or longer, it leaves the value out, which is why this message has nothing between them. Values that long tend to come from file names written as whole sentences, or from a block of text pasted into a link field by mistake. To find the link, check the source line shown with the issue, or search the page source for href values that contain spaces.
The fix is the same as for a short URL: replace each space with %20. If you control the file, a short name with hyphens instead of spaces, such as annual-report.pdf, is easier to link to. If the href holds text that was never meant to be a URL, put the right address back in the link.
Invalid example
<a href="/downloads/reports/Annual report on community health programs and volunteer outreach in the northern region with survey results, budget breakdown and recommendations for the next two financial years.pdf">
Download the annual report
</a>
Valid example
<a href="/downloads/reports/Annual%20report%20on%20community%20health%20programs%20and%20volunteer%20outreach%20in%20the%20northern%20region%20with%20survey%20results,%20budget%20breakdown%20and%20recommendations%20for%20the%20next%20two%20financial%20years.pdf">
Download the annual report
</a>
The path in a <form> element's action can't contain a literal space, so write each space as %20 or rename the target so its URL has none.
The action attribute holds the URL that receives the submitted form data, and the URL Standard doesn't allow spaces in a path. The validator reports it for values like /contact us/send.php or ./privacy policy.aspx. Accented letters such as í or ñ are allowed in a path, so only the space needs fixing.
Some server frameworks write the current page's file name into action when a form posts back to the same page. If that file name has a space in it, every page built from it reports this error, and renaming the file or route fixes all of them at once.
Browsers percent-encode the space before they submit, so the form usually still works. A crawler or a script that reads the raw value may not do the same, and the markup is invalid either way. Spaces at the very start or end of the value are allowed, because the URL parser strips them. A space after the ? gives a different message, Illegal character in query, and %20 fixes that one too.
Invalid example
<form method="post" action="/contact us/send.php">
<label>
<input type="email" name="email">
</label>
<button type="submit">Send</button>
</form>
Valid example: space encoded as %20
<form method="post" action="/contact%20us/send.php">
<label>
<input type="email" name="email">
</label>
<button type="submit">Send</button>
</form>
Valid example: hyphen instead of a space
<form method="post" action="/contact-us/send.php">
<label>
<input type="email" name="email">
</label>
<button type="submit">Send</button>
</form>
The path in an <object> element's data attribute can't contain a literal space, so write each space as %20 or rename the file so its URL has none.
The data attribute holds the URL of the resource the object embeds, often a PDF, and the URL Standard doesn't allow spaces in a path. The validator reports values like /docs/annual report.pdf, and one stray space is enough, as in /docs/fees_ 2025.pdf. Accented letters in a file name are allowed, so only the space needs fixing.
Browsers percent-encode the space when they request the file, so the embedded document usually still shows. The markup is invalid anyway, and a tool that reads the raw value may not encode it. A space after the ? gives a different message, Illegal character in query, and %20 fixes that one too.
When the object has a fallback link to the same file, the link's href gets its own Illegal character in path segment error. Change both values together.
Invalid example
<object data="/docs/annual report.pdf" type="application/pdf" width="600" height="800">
<p><a href="/docs/annual report.pdf">Download the annual report (PDF)</a></p>
</object>
Valid example: space encoded as %20
<object data="/docs/annual%20report.pdf" type="application/pdf" width="600" height="800">
<p><a href="/docs/annual%20report.pdf">Download the annual report (PDF)</a></p>
</object>
Valid example: hyphen instead of a space
<object data="/docs/annual-report.pdf" type="application/pdf" width="600" height="800">
<p><a href="/docs/annual-report.pdf">Download the annual report (PDF)</a></p>
</object>
The href value on the <a> element has a literal ^ (caret) in its path, and a URL can only carry that character percent-encoded as %5E.
The URL standard doesn't list ^ among the characters a URL can contain. Browsers still follow the link, but the markup is invalid.
The caret usually comes from a file name. A document saved as meeting-minutes-^2.pdf and uploaded to a CMS keeps the caret in its address, and every link to it repeats it. Rename the file without the caret and update the links, adding a redirect from the old address if other sites link to it. If the file has to keep its name, write the caret as %5E in the href. The server decodes %5E back to ^ when it looks up the file, so the encoded link still opens the same document.
A caret in the query string or the fragment gets a different message, ending in "Illegal character in query" or "Illegal character in fragment". When the href is very long, the validator leaves the value out of the message. The cause and the fix are the same.
Invalid example
<a href="/files/meeting-minutes-^2.pdf">Meeting minutes (PDF)</a>
Valid example
Rename the file so its name has no caret:
<a href="/files/meeting-minutes-2.pdf">Meeting minutes (PDF)</a>
If the file name can't change, percent-encode the caret:
<a href="/files/meeting-minutes-%5E2.pdf">Meeting minutes (PDF)</a>
The href of this link contains a curly brace, usually from template syntax like {{ ... }} that reached the HTML without being replaced by a real URL.
Curly braces aren't allowed in URLs. When a placeholder such as {{ menu.link }} or {id} ends up in the page, the browser gets the placeholder text instead of an address. A value like {{ menu.link }}, with no scheme or leading slash, is a relative URL, so the brace counts as part of the path. That's why the validator mentions a path segment. A stray } in the path gets the same message with } in place of {. A brace in the query string or the fragment is reported with a different message.
Client-side frameworks often cause this. In AngularJS, href="{{ menu.link }}" puts the raw expression in the HTML, and anything that reads the page before the script runs sees it: the validator, a crawler, or a visitor whose JavaScript failed to load. AngularJS has the ng-href directive for this case. Write it as data-ng-href so the attribute is valid HTML, and AngularJS sets href once the expression has a value. Until then the link has no href and can't be reached with the keyboard, so rendering the final URL on the server is the more reliable fix.
If the braces are meant to be literal characters in the URL, percent-encode them: { as %7B and } as %7D.
Invalid example
<a href="{{ menu.link }}">Products</a>
Valid example
The server renders the final URL:
<a href="/products/">Products</a>
Valid example with AngularJS
<a data-ng-href="{{ menu.link }}">Products</a>
The href value on the <a> element contains  (U+FFFC, the object replacement character), which isn't allowed in a URL path.
Rich-text editors and other text systems use U+FFFC as a placeholder for an inline image or other embedded object. Copying text out of one of them, or editing a link next to an inline image, can leave the placeholder inside the URL. Depending on the font, it's invisible or shows up as a small box, so the address can look right in the editor.
It never belongs in an address. Browsers send it as %EF%BF%BC, so /jobs/apply/ is requested as /jobs/apply%EF%BF%BC/, which most likely doesn't exist. Percent-encoding it yourself silences the validator but the link stays broken, so delete the character instead. Retyping the URL in the link field, or editing the link in the editor's HTML view, gets rid of it. To find every occurrence in a template or an export, run a regular-expression search for \uFFFC or \x{FFFC}, depending on the tool.
The same character in a query string or a fragment gets a similar message that names the query or the fragment instead of a path segment.
Invalid example
<a href="/jobs/apply/">Apply now</a>
Valid example
<a href="/jobs/apply/">Apply now</a>
The href value on the <a> element contains a literal | (pipe) character, which is not allowed in a URL path.
The URL standard doesn't list | among the characters a URL can contain, so a pipe in the path has to be written as %7C. Browsers still follow the link, but the markup is invalid.
This usually comes from a CMS or template that builds the path from a page title. A title like "Summer concert | Tickets" uses the pipe as a separator. If the slug function only lowercases the text and turns spaces into hyphens, the | stays and the path ends up as summer-concert-|-tickets. Fix the slug function so it drops anything other than letters, digits and hyphens. The new slug gives the page a new address, so redirect the old URL to it. If the URLs can't change, write the pipe as %7C in the href instead.
When the href is very long, the validator leaves the value out of the message. The cause and the fix are the same.
Invalid example
<a href="/events/42/summer-concert-|-tickets">Summer concert | Tickets</a>
Valid example
Remove the pipe from the slug:
<a href="/events/42/summer-concert-tickets">Summer concert | Tickets</a>
If the URL has to stay the same, percent-encode the pipe:
<a href="/events/42/summer-concert-%7C-tickets">Summer concert | Tickets</a>
The src attribute on a <script> element points to a URL whose path contains a character that is not allowed there unless it is percent-encoded.
A URL path may only use a restricted set of characters. Symbols such as ^, spaces, square brackets, and backticks have to be written in their percent-encoded form, so a caret becomes %5E. The validator names the exact character it rejected, so look at the path segment it points to and either encode that character or change the URL so it no longer appears.
A common source of the ^ character is a version range copied from a package manager. A specifier like @^2 belongs in a package.json file, not in a CDN URL. When you load a script straight from a CDN, pin an explicit version instead.
Invalid example
<script src="https://cdn.example.com/pkg@^2/dist/app.js"></script>
Valid example
<script src="https://cdn.example.com/pkg@2.1.0/dist/app.js"></script>
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.
1K Weekly
1,000 monthly checks. Cancel anytime.
Get 1K Weekly →Join teams across 40+ countries