Nested links break a content card's navigation
Diagnose cards that wrap one link around another, compare delivered HTML with the browser DOM, and build distinct readable destinations without invalid nesting.
By Crawlito · 5 min read
In short
- An anchor must not contain another anchor in valid HTML.
- Browser parsing can produce a DOM that differs from the nested source markup.
- Give each destination a clear link and verify keyboard, pointer, and direct navigation.
On this page
- Inspect the delivered and parsed markup
- Reproduce each intended action separately
- Trace the nesting to component composition
- Use a valid structure with distinct links
- Verify the browser's final link graph
- Check cards created from rich text and CMS content
- Explain the crawler and reader implications carefully
- Frequently asked questions
If a content card opens the wrong page or has inconsistent clickable areas, check whether an outer anchor wraps another link inside it. Nested anchors are invalid HTML, and browser parsing can change the structure you expected. Give each destination its own valid link, then verify the parsed document and the reader's navigation.
This often appears when a whole card links to an article while its author, category, or secondary action is also a link. The design can be supported, but the markup needs a coherent structure.
Inspect the delivered and parsed markup
Save the public HTML around one failing card. Then inspect the same card in the browser's Elements panel.
A simplified invalid example is:
<a href="/blog/setup">
<h2>Setup guide</h2>
<a href="/authors/editor">About the author</a>
</a>MDN's anchor reference describes the permitted content and excludes nested anchors. The browser may repair invalid input into a structure different from the one the template author imagined.
Do not use a screenshot to decide whether the markup is valid. The page can look normal while the actual links and click targets differ.
Record the outer destination, inner destination, source markup, and parsed DOM. That evidence explains the problem more clearly than saying “the card sometimes clicks wrong.”
Reproduce each intended action separately
Click the article title, a non-link area of the card, and the author link. Then test keyboard navigation and opening each link in a new tab.
Write the intended behavior before changing code. Does the whole card need to navigate, or is a clear title link sufficient? Which secondary actions must remain independently usable?
A useful action table is:
| Area | Intended destination |
|---|---|
| Article title | Article page |
| Author name | Author profile |
| Category label | Category archive, if linked |
| Empty card space | Explicit design choice |
| Keyboard focus | Clear, distinct controls |
Do not let a JavaScript event handler silently override those destinations. A real link's href should agree with the action a reader expects.
The JavaScript navigation guide explains why real link destinations matter beyond click handlers.
Trace the nesting to component composition
Inspect how the card, title, author, and category components are composed. Each may be valid alone while their combination creates invalid nesting.
A reusable card wrapper may always render an anchor, while a child component also renders an anchor when an optional URL is present. That makes the defect data-dependent.
Test a card without secondary links and one with every supported field. The first can look correct while the richer card fails.
Check server rendering and client updates as well. A framework warning may point to the invalid structure, but use the actual public output as evidence.
The raw versus rendered HTML guide helps compare those stages. A browser-repaired DOM can differ before application scripts run, so do not assume every difference is caused by hydration code.
Keep the repair in the component contract that permits the invalid combination.
Use a valid structure with distinct links
One straightforward design uses a non-link container with separate title and author links:
<article class="card">
<h2><a href="/blog/setup">Setup guide</a></h2>
<p>By <a href="/authors/editor">the editor</a></p>
</article>This example demonstrates structure, not a complete visual design. Preserve the site's styling and accessible labels through its normal component system.
If the design requires a larger click target, implement it without putting interactive elements inside another anchor. Review the actual CSS and focus behavior rather than copying an overlay pattern blindly.
Do not replace all links with generic div elements and click handlers just to avoid invalid nesting. That can remove native link behavior and make navigation harder to inspect.
Keep each destination visible and meaningful to the reader. The article title should not navigate somewhere different because a parent listener captured the event.
Verify the browser's final link graph
After the change, inspect the parsed DOM and list the links within the card. Confirm their text and href values describe the intended destinations.
Then test the same pointer and keyboard sequence used before the repair. Include new-tab behavior and browser back navigation where relevant.
Fetch the destinations and confirm they serve the correct article, author, or category page. A valid anchor to a broken URL is still a navigation defect.
The broken internal links guide covers that destination layer. Keep markup validity and destination validity as separate checks.
Test multiple cards on the same page. An overlay or event handler can accidentally extend beyond its card and capture clicks intended for another item.
A completed repair should have both valid structure and predictable user actions.
Check cards created from rich text and CMS content
Some CMS fields permit inline links in titles or summaries. If a template wraps the entire field in another anchor, an editor can introduce nesting without changing code.
Define which fields may contain links and render them accordingly. A plain title field and a rich summary field need different handling.
Do not strip all useful links from content as a broad workaround unless that matches the editorial contract. Instead, avoid wrapping arbitrary linked content in another anchor.
Test an imported summary with a link, an author with a profile URL, and a category badge. These examples express the actual composition risks.
For a migration, compare the browser DOM for representative cards rather than only matching the visual grid. A redesigned component can preserve appearance while changing navigation semantics.
Document the component's allowed children so future additions do not recreate the invalid structure.
Explain the crawler and reader implications carefully
A malformed card does not prove a specific search crawler missed every destination. Different parsers and processing stages can produce different outcomes.
The concrete finding is that the published markup was invalid and the tested browser's links did not match the intended card behavior. The repair makes those destinations explicit and usable.
For an audit, include one before example and the final link list. This gives the developer and content owner evidence they can inspect without relying on a score alone.
After a component release, test a card with multiple destinations as part of the page sample. A simple single-link card is not enough to exercise the failure.
Keep conversion conclusions separate. Restoring a usable next step removes a real obstacle, but increased signups or inquiries require measured outcomes.
When JavaScript hydrates or updates the card, inspect the DOM before and after that step. The HTML parser's initial repair and a later component update are different moments in the page lifecycle. A final screenshot can hide the fact that a destination briefly existed under a different structure.
Use the browser's link inspection and keyboard navigation together. The former identifies the actual destination; the latter shows whether the separate actions can be reached in a sensible order. If an overlay click handler remains, test text selection and opening each real link in a new tab. Preserve normal link behavior while correcting the composition error.
Frequently asked questions
Can I place an author link inside a linked article card?
Use a valid structure that keeps the links distinct. Do not nest one anchor inside another.
Why does the DOM differ from my template source?
HTML parsing can repair invalid markup. Compare the delivered source with the parsed structure before blaming application scripts.
Should I use stopPropagation as the whole fix?
An event change does not make nested anchors valid. Repair the structure and then verify any remaining event behavior.
Run the archive page through the free Crawlito check after checking its card links and destinations.
Filed under Structure and schema. Topics: html, internal-links, javascript