1.4 Rendering & JavaScript ✦HighVerified

Links as span/div with JS onclick

What it is

Google follows real anchor tags with href attributes. A span or div wired up with a JavaScript onclick looks like a link to a user but is invisible as a link to a crawler. Navigation uses non-anchor elements with handlers.

Why does links as span/div with js onclick matter for AI search?

Google primarily follows real <a href> links; JS-handler ‘links’ may not be crawled, breaking discovery.

How do you fix it?

Use real <a href> anchors for navigation.

How do you find it on your site?

  1. Inspect navigation elements and check they are anchor tags with href, not span or div with onclick.
  2. Crawl the site and see whether those destinations are discovered.
  3. Replace scripted click handlers with proper anchor elements.
  4. Keep JavaScript enhancements layered on top of real links.

Which ranking and citation factors does it touch?

Only resolvable href links pass crawl paths and link signals. Scripted pseudo-links break both.

What is the impact?

Medium-high; discovery. Direct.

What is the evidence?

Use proper <a href> links so Google can follow them. Google Search Central, Understand JavaScript SEO Basics; Google Search Central, SEO Starter Guide

Frequently asked questions about links as span/div with js onclick

What does "Links as span/div with JS onclick" mean?

Navigation uses non-anchor elements with handlers.

How do you fix links as span/div with JS onclick?

Use real <a href> anchors for navigation.