diff --git a/packages/svelte/messages/compile-warnings/a11y.md b/packages/svelte/messages/compile-warnings/a11y.md index a299fa53bc89..9c07feadc7a5 100644 --- a/packages/svelte/messages/compile-warnings/a11y.md +++ b/packages/svelte/messages/compile-warnings/a11y.md @@ -189,9 +189,65 @@ Enforce that elements with an interactive role and interactive handlers (mouse o Enforce that attributes important for accessibility have a valid value. For example, `href` should not be empty, `'#'`, or `javascript:`. +**Why this matters for accessibility:** +- Screen readers announce links to users, but `href="#"` provides no meaningful destination information +- Users who navigate by links (a common screen reader navigation method) will encounter unhelpful link descriptions +- `href="#"` scrolls to the top of the page when clicked, which can be disorienting +- Opening in a new tab results in the same page or a blank page +- These links cannot be bookmarked or shared + +**Common mistakes and their solutions:** + +```svelte + +Click me + + +Click me + + +Click me +``` + +**Better alternatives:** + +If you need an element that performs an action (not navigation), use a button: +```svelte + + +``` + +If you need a link that looks like a button, style the button appropriately: +```svelte + + + + +``` + +For actual navigation, provide a valid href: +```svelte + +Go to page +Go to section +``` + +If you're creating a placeholder link during development: ```svelte - -invalid + +Coming soon ``` ## a11y_label_has_associated_control