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

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-http-for-attribute-href-on-element-a-invalid-host-empty-host
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

When you set `href="http://"`, the browser and the W3C validator attempt to parse this as an absolute URL. According to the [URL Standard](https://url.spec.whatwg.org/), a URL with the `http` or `https` scheme must include a non-empty host component. The string `http://` has the scheme but nothing after the `://`, which makes the host empty and the URL invalid.

This issue typically arises when a URL is dynamically generated but the variable or value for the domain is missing, or when a developer uses `http://` as a temporary placeholder during development and forgets to replace it.

### Why this matters

- **Broken navigation:** Clicking a link with `href="http://"` leads to unpredictable behavior. Some browsers may navigate to an error page, while others may interpret it differently.
- **Accessibility:** Screen readers announce links to users, including their destinations. An invalid URL creates a confusing experience for assistive technology users who expect the link to go somewhere meaningful.
- **Standards compliance:** The HTML specification requires that `href` values be valid URLs. An empty host violates the URL parsing rules, causing the W3C validator to flag it as an error.
- **SEO:** Search engine crawlers may treat invalid URLs as errors, potentially affecting how your site is indexed.

## Examples

### ❌ Invalid: empty host in URL

```html
<a href="http://">Visit our website</a>
```

This triggers the error because `http://` has no host component.

### ❌ Invalid: same issue with HTTPS

```html
<a href="https://">Secure link</a>
```

The `https` scheme also requires a valid host, so this produces the same error.

### ✅ Fixed: provide a complete URL

```html
<a href="https://example.com">Visit our website</a>
```

### ✅ Fixed: use a fragment placeholder if the URL is unknown

If you need a placeholder link during development, use `#` instead of an incomplete URL:

```html
<a href="#">Visit our website</a>
```

### ✅ Fixed: use a relative URL when linking within the same site

```html
<a href="/about">About us</a>
```

### Handling dynamic URLs

If the `href` value comes from a template or CMS, make sure the variable outputs a complete URL. For example, if a template produces an empty string, you might end up with:

```html
<!-- If {{ site_url }} is empty, this becomes href="http://" -->
<a href="http://{{ site_url }}">Home</a>
```

Ensure that the variable always resolves to a valid host, or add a fallback so the link is omitted or replaced with a safe default when the value is missing.
