<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-link/usage/ in the magma monorepo.
-->

# mds-link - mistakes

> The API of this component: [`AGENTS.md`](AGENTS.md).

Common incorrect uses of `<mds-link>`. Each entry pairs the wrong form with the right one and a one-line reason. System-wide rules (boolean-as-string, shadow piercing, Tailwind color utilities, raw native event listening) live in [`agents/mistakes.md`](../../../../agents/mistakes.md) - they apply here too but are not repeated.

#### Do Not Use `mds-button` for a Link Inside a Sentence

`mds-button` is a block-level control with its own typography and padding: inside a sentence it breaks the line and the font. A word that links belongs to `mds-link`.

```html
<!-- INCORRECT -->
<mds-text typography="paragraph">
  Leggi l'<mds-button href="/privacy" tone="text" label="informativa"></mds-button> prima di continuare.
</mds-text>

<!-- CORRECT -->
<mds-text typography="paragraph">
  Leggi l'<mds-link href="/privacy">informativa</mds-link> prima di continuare.
</mds-text>
```

#### Do Not Use `mds-link` for a Standalone Action

A call to action, a form submit or a step of a flow is a control, not a word of a sentence: it needs the size, the variants and the form participation of `mds-button`.

```html
<!-- INCORRECT -->
<form>
  <mds-link>Invia la richiesta</mds-link>
</form>

<!-- CORRECT -->
<form>
  <mds-button type="submit" label="Invia la richiesta"></mds-button>
</form>
```

#### Do Not Navigate From a Click Handler

A link without `href` is a button for the browser: no new tab on a modifier click, no context menu, no address to copy, and the assistive technology announces a button. Give the URL to `href`.

```html
<!-- INCORRECT -->
<mds-link onclick="location.href = '/privacy'">informativa</mds-link>

<!-- CORRECT -->
<mds-link href="/privacy">informativa</mds-link>
```

#### Do Not Style a Raw Anchor Inside `mds-text`

A hand-styled `<a>` drifts from app to app in color, underline and hover, and usually loses the focus ring.

```html
<!-- INCORRECT -->
<mds-text typography="paragraph">
  Leggi l'<a href="/privacy" class="text-accent-fg underline">informativa</a>.
</mds-text>

<!-- CORRECT -->
<mds-text typography="paragraph">
  Leggi l'<mds-link href="/privacy">informativa</mds-link>.
</mds-text>
```

#### Do Not Write the New-Tab Notice Yourself

With `target="blank"` the component already tells the assistive technology the link opens a new tab, in the language of the page: a notice in the text is read twice.

```html
<!-- INCORRECT -->
<mds-link href="/report.pdf" target="blank">Rapporto (si apre in una nuova scheda)</mds-link>

<!-- CORRECT -->
<mds-link href="/report.pdf" target="blank">Rapporto</mds-link>
```

#### Do Not Remove the Underline

Without the underline the link is told from the text only by its color, which fails users who cannot see it (WCAG 1.4.1). For a quieter line, lower the `tone`.

```css
/* INCORRECT */
mds-link::part(link) {
  text-decoration: none;
}

/* CORRECT */
/* <mds-link href="/privacy" tone="weak">informativa</mds-link> */
```
