Notes

Put card buttons beside links, not inside them

Give navigation and actions separate HTML controls. A sibling link and button work with the mouse, keyboard and assistive technology without event-cancellation patches.

A card often needs two actions: open its detail page and save it for later. Wrapping the whole card in a link and putting a button inside that link creates nested interactive content. Cancelling a click can hide one symptom, but leaves invalid markup and confusing keyboard behavior.

An anchor with an href must not contain interactive descendants such as buttons. Give navigation a link and the action its own button. Both can live in the same visual card.

Use separate controls

Save this as a standalone HTML file to try the complete example:

<!doctype html>
<html lang="en">
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>Separate card actions</title>
  <article>
    <h2><a href="#details">A guide to browser rendering</a></h2>
    <p>From a document tree to pixels on screen.</p>
    <button type="button" aria-pressed="false" id="save">
      Save guide
    </button>
    <p role="status" id="status"></p>
  </article>
  <section id="details">
    <h2>Guide details</h2>
    <p>The link navigates here. Saving does not navigate.</p>
  </section>
  <script>
    const button = document.getElementById("save");
    const status = document.getElementById("status");
    button.addEventListener("click", () => {
      const saved = button.getAttribute("aria-pressed") !== "true";
      button.setAttribute("aria-pressed", String(saved));
      status.textContent = saved ? "Guide saved." : "Guide removed.";
    });
  </script>
</html>

The toggle keeps a stable accessible name, while aria-pressed communicates its state. type="button" prevents an accidental form submission if the card later moves into a form. This example stores state only in the page; a persistent save action needs application storage or a server operation.

There is no navigation handler on the article and no default behavior to cancel. The browser already knows how to activate both controls.

Default actions and propagation are different

event.preventDefault() cancels a cancellable browser default action. event.stopPropagation() prevents an event from reaching later ancestors in its propagation path. Neither changes the HTML content model, and stopping propagation does not itself cancel navigation.

If you control the card markup, fix its structure. Avoid adding a wrapper click handler that turns every click into navigation: text selection, modified clicks and child actions then require extra exceptions. A real link already supports opening in a new tab, copying the destination and normal browser context menus.

A stretched-link CSS treatment is possible, but the overlay must not cover the button or prevent selecting useful text. A visible title link is the simpler starting point and usually enough to communicate navigation.

Check the interaction

Tab should focus the title link, then the save button. Enter on the link should navigate. Space or Enter on the button should toggle its pressed state without changing the URL. The status message should change without moving focus away from the button.

The HTML anchor content model defines the nesting restriction. For how events and rendering turn into visible updates, continue with browser rendering.