The href attribute holds the URL that a link points to, as in <a href="/pricing">Pricing</a>. The HTML standard says an a element without href does not create a hyperlink. For SEO, this small attribute decides whether a link exists as far as a crawler is concerned, which makes it a frequent cause of problems on JavaScript-heavy sites.
Need help with SEO?
Comppound runs SEO and AI search for SaaS companies. We plan what to publish, produce it with AI, and every page passes automated checks, and a person reviews samples and anything high-risk.

- Published to your site and tracked in Search Console
- One person answers for your account
- Plans from $400 a month, terms from 3 months
What Google can and cannot follow
Google's link guidance recommends standard anchor elements with an href that resolves to a real web address. Links inserted with JavaScript are fine if they use the same markup. Google may still try to parse other patterns, but it says it cannot reliably extract URLs from anchor elements without href.
Recommended:
<a href="/products/category/shoes">Shoes</a>
<a href="./products/category/shoes">Shoes</a>
Not recommended:
<a routerLink="products/category">Shoes</a>
<span href="https://example.com">Shoes</span>
<a onclick="goto('https://example.com')">Shoes</a>
<a href="javascript:goTo('products')">Shoes</a>Relative and absolute values
An href can be absolute, with the full address, or relative to the current page. Both work when they resolve correctly. The HTML standard requires the value to be a valid URL, with surrounding spaces allowed. Relative links can break when content is copied to another path, so test them after template changes.
Other attributes can sit alongside href without harm. A link with an onclick handler is fine as long as the href is a real URL.
Other uses of href
The same attribute appears on link elements, where it carries the URL for tags such as rel="canonical" and hreflang alternates. Tags like these are not visible links, but a wrong value can send a strong signal to the wrong page, so include them in template checks.
Example
Navigation that crawlers could not see
Hypothetical analytics SaaS Brightquill rebuilt its site navigation with buttons that changed the route in a click handler. It worked for visitors, but a site crawl found few links beyond the homepage.
The team swapped the buttons for anchor elements with real href values and kept the client-side routing for the click itself. Visitors saw no difference, and the pages became reachable in the crawl.
Common mistakes
Using # or javascript: as the destination
A link that exists only to trigger a script gives a crawler no real page to fetch. If it goes somewhere, give it the real URL. If it opens a menu, use a button.
Checking only the raw HTML or only the page view
Links added by JavaScript appear in rendered HTML, and URL Inspection will show them. Check there rather than judging from the visual page.
Frequently Asked Questions
Yes, as long as they resolve to a real address. Google's own recommended examples include relative paths.
Yes. Google recommends concise, descriptive link text that makes sense out of context, and it warns against phrases such as click here.
Keep reading
- Anchor Text: Anchor text is the clickable text of a link. It tells readers and search engines what to expect on the page the link points to.
- Internal Linking: Internal linking is linking from one page on your site to another. It helps search engines find and understand pages and guides readers to the next step.
- JavaScript SEO: JavaScript SEO is the practice of making sure pages built with JavaScript can be crawled, rendered and indexed by search engines and AI crawlers.
- Crawlability: Crawlability is how easily search engine and AI crawlers can discover and fetch the pages on a site.
- Bing Webmaster Tools: Bing Webmaster Tools is Microsoft's free console for site owners. It shows how Bing crawls and indexes a site and offers SEO reports and URL submission.
- Content delivery network: A CDN is a network of servers worldwide that caches and serves a site's files close to each visitor, cutting load times and shielding the origin server.
- Crawl Errors: Crawl errors are failures that happen when a search engine tries to fetch a URL, such as server errors, redirect problems, blocked pages or DNS failures.
- Googlebot: Googlebot is the web crawler Google uses to fetch pages for Search. It discovers URLs, downloads them and passes them on to be rendered and indexed.
