Skip to content
WordPressRule: nested-interactive•Reviewed Oct 2026

Avoid nesting interactive controls within each other in WordPress

Do not nest buttons, links, or inputs inside other clickable buttons or links.

What's wrong

Nesting a `<button>` inside an `<a>` tag creates invalid HTML and unpredictable keyboard/screen reader focus.

Who it affects

Keyboard and screen reader users cannot activate the inner button, or clicking activates both actions simultaneously.

How to fix on WordPress

Separate clickable post card links from inner category pills or bookmark buttons.

Code example

Problematic Code
PHP
<a href="<?php the_permalink(); ?>" class="post-card">
  <h2><?php the_title(); ?></h2>
  <a href="/category/news" class="badge">News</a>
</a>
Recommended Accessible Code
PHP
<div class="post-card">
  <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  <a href="/category/news" class="badge">News</a>
</div>

How to check your fix

Run an axe audit or inspect the DOM to confirm no `<a>` tag contains another `<a>`, `<button>`, or `<input>`.

Check if your site has this issue

Scan any public store page free against WCAG 2.2 AA in 30 seconds.

Your session has ended

Sign in again to carry on. Anything you typed on this page is kept.

Signed in another way? Use another method (opens a new tab)