# Links

Links are used primarily as a navigational element. Links may also change what or how data is displayed (i.e., view more, show all). If the action taken by the user will change or manipulate data, use a [button](<https://element.siemens.io/components/buttons-menus/buttons/>).

## Usage

![Links](<../images/link.png>)

### Best practices

- Use text for links rather than graphics or icons.
- Links should be three words or less.
- Text should be consistent with the title of the intended destination.
- Use caution with links that are several words long. It is recommended that links are long enough to be understood by the user, but short enough to prevent text wrapping.
- Avoid the term “click here,” other links to “here,” or the web address itself. Instead, use a meaningful descriptive label for the link, and match the destination site name.
- Links in paragraphs should always be underlined to ensure they’re easily recognized. As standalone elements (e.g., in cards or lists), underlines aren’t needed and an arrow icon (\>) can be used to clarify function.
- If a link needs to trigger an action instead of navigating (e.g., opening a modal or expanding content), use a button link instead.

## Design

### States

Links support the different styles: default/visited, hover, pressed, focused and disabled.

![Links](<../images/link-usage-construction.png>)

### Styles

The visual representation of **Bold** or "Normal" depends on the surrounding context.

### Recommendation

Links can be grouped horizontally or vertically (e.g. in footers). In this case it's recommended to have a proper distance between grouped links.

### Links vs. button links

Links, built with the `<a>` HTML element, are strictly for navigation. If an action does not involve navigating to another page, use a [button link](<https://element.siemens.io/components/buttons-menus/buttons/#button-link>) instead. This ensures correct semantics, accessibility, and behavior.

## Code

The link styling is applied to the standard HTML `a` element. For links inside a paragraph, add the class `.link-text` to add the underline.

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component } from '@angular/core';

@Component({
  selector: 'app-sample',
  templateUrl: './links.html',
  host: { class: 'p-5' }
})
export class SampleComponent {}
```

Template:

```html
<a href="#">Default Link</a><br />
<a href="#" target="_blank">Link in new Window</a><br />

<a href="#">
  <i aria-hidden="true" class="link-icon element-right-2 flip-rtl"></i>
  Default Icon Link </a
><br />
<a href="#" target="_blank">
  <i aria-hidden="true" class="link-icon element-right-2 flip-rtl"></i>
  Icon Link in new Window </a
><br />

<a href="#">
  Default Icon Link
  <i aria-hidden="true" class="link-icon element-right-2 flip-rtl"></i> </a
><br />
<a href="#" target="_blank">
  Icon Link in new Window
  <i aria-hidden="true" class="link-icon element-right-2 flip-rtl"></i> </a
><br />

<a href="#"><b>Default Link</b></a
><br />
<a href="#" target="_blank"><b>Link in new Window</b></a
><br />

<a href="#">
  <b>
    <i aria-hidden="true" class="link-icon element-right-2 flip-rtl"></i>
    Default Icon Link
  </b> </a
><br />
<a href="#" target="_blank">
  <b>
    <i aria-hidden="true" class="link-icon element-right-2 flip-rtl"></i>
    Icon Link in new Window
  </b> </a
><br />

<a href="#">
  <b>
    Default Icon Link
    <i aria-hidden="true" class="link-icon element-right-2 flip-rtl"></i>
  </b> </a
><br />
<a href="#" target="_blank">
  <b>
    Icon Link in new Window
    <i aria-hidden="true" class="link-icon element-right-2 flip-rtl"></i>
  </b> </a
><br />

<button type="button" class="btn btn-link">Button Link</button>
<br />
<button type="button" class="btn btn-link">
  <span>
    Button Link with icon
    <i aria-hidden="true" class="link-icon element-right-2 flip-rtl"></i>
  </span>
</button>

<p>
  This is a paragraph of text with an <a href="#" class="link-text">embedded link</a> that needs the
  class <code>.link-text</code> to be accessible.
</p>
```
