Skip to main content
HTML Validation

Bad value “//X” for attribute “href” on element “a”: Invalid host: empty host.

About This HTML Issue

A URL that starts with // needs a host name right after the two slashes, and this href has none.

An href such as //example.com/news is a scheme-relative URL. The browser keeps the scheme of the current page (http: or https:) and reads everything after the //, up to the next /, ? or #, as the host. In //?page=news, //#contact or a bare //, that part is empty. The URL Standard rejects a URL with no host, so the link has no valid destination.

The extra slash usually comes from a typo, or from a template that glued a base path ending in / onto a path starting with /. In that case the link was meant to be root-relative: /?page=news is the site's home page with a query string, and /#contact is an anchor on that page. Drop one slash and the error goes away. If the link goes to another site, put that site's host after the slashes, or write the full address, such as https://example.com/?page=news.

Invalid example

<nav>
  <a href="//?page=news">News</a>
  <a href="//#contact">Contact</a>
</nav>

Valid example

<nav>
  <a href="/?page=news">News</a>
  <a href="/#contact">Contact</a>
</nav>

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