> For the complete documentation index, see [llms.txt](https://docs.webstudio.is/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.webstudio.is/university/core-components/link.md).

# Link

Link lets you link to websites, pages, emails, and more from text, images, and more.

> See [MDN: \<a>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)

{% embed url="<https://www.youtube.com/watch?v=XPzFZ67zRrU>" %}

***

## How to use the Link component

The "Link Component" can be found in Components > General, and you can place it on your canvas by dragging and dropping it or clicking it in the Components panel.

You can convert anything into a link by wrapping it inside the Link component, including text and images. These links can direct users to different pages within your site or lead to external resources, including other websites, downloadable files, or email addresses.

***

## How to customize a Link instance's properties

You can customize the properties of a Link instance by selecting it and going to "Settings." Here is an overview of each property:

### Href

<figure><picture><source srcset="https://330243581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTep4EGj6hSC54ozHujyK%2Fuploads%2Fgit-blob-2180eef7a012ef904d477cba110776a90041bca3%2Flink-href-property-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://330243581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTep4EGj6hSC54ozHujyK%2Fuploads%2Fgit-blob-aa44c539f3eb1e0c1517d286c544dbe5c8639bf8%2Flink-href-property-light.png?alt=media" alt="Link settings with destination type choices and Href field" width="240"></picture><figcaption></figcaption></figure>

The "href" property determines what the Link instance will lead to, such as a URL, page, phone, attachment, or email address.

1. **URL**: In its most common form, the "href" property references a URL, linking to another website or page.
2. **Page**: You can link to all of your pages within your site here. You can also link to specific sections within those pages. To link to a section on a page, first go to the section and fill out the `ID` field in Settings. Then go back to the link, select the page, and then in the next dropdown select the `ID` you just created. Like this:

   <div align="center"><figure><img src="https://330243581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTep4EGj6hSC54ozHujyK%2Fuploads%2Fgit-blob-6f79fb5adcff83ec33bd0816a0f7c81c0a1ff89e%2Fsection-id.png?alt=media" alt="Section settings with an ID entered as the anchor destination" width="375"><figcaption><p>First add the ID to the section you want to link to</p></figcaption></figure></div>

   <div align="center"><figure><img src="https://330243581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTep4EGj6hSC54ozHujyK%2Fuploads%2Fgit-blob-7efc28b96c91994e64de3f9760ea92e76f1e286a%2Flink-to-section.png?alt=media" alt="Link destination picker with a section selected on the current page" width="375"><figcaption><p>Then add a page link and select the section.</p></figcaption></figure></div>
3. **Email**: When you specify an email address as the 'href' value, the link opens the user's default email client (such as Gmail) with the designated email address pre-filled.
4. **Phone**: If you set the "href" property to a phone number, the link becomes a prompt for users to initiate phone calls directly from their devices.
5. **Attachment**: You can also link to downloadable attachments such as PDFs, documents, or media files, allowing users to initiate file downloads with one click.

### Target

The `target` property controls where the link opens. Choose one of these values:

1. **`_self`**: Opens the link in the same tab. This is the default.
2. **`_blank`**: Opens the link in a new tab or window.
3. **`_parent`**: Opens the link in the parent browsing context. This is mainly useful inside nested frames.
4. **`_top`**: Opens the link in the top-level browsing context, replacing any frames.

To open a link in a new tab, set **Target** to **`_blank`**.

### Prefetch

The "Prefetch" property enables near-instant page transitions by preloading linked pages before the user clicks. This dramatically improves perceived navigation speed.

1. **Intent**: The browser loads the destination page when the user hovers over the link. This is ideal for most links as it balances performance with resource usage.
2. **Render**: The browser loads all destination pages as soon as the current page renders. Best for simple pages or funnels with very few links.
3. **Viewport**: The browser loads the destination page when the link enters the user's viewport. Good for links that appear below the fold.

For most websites, use "Intent" or "Viewport" to provide fast navigation without overloading the browser with pages to preload.

## Wrapping Components in Links

You can add any Webstudio component inside a Link element to make it clickable — images, videos, text, buttons, or even custom HTML embeds. Simply drag the component into the Link or wrap existing content by selecting it and using the Link component.

## How to style the current page state

When using links for navigation and wanting to highlight the current page, the link component has a "Local Link" state in every style source.

<figure><picture><source srcset="https://330243581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTep4EGj6hSC54ozHujyK%2Fuploads%2Fgit-blob-063e4ed8eefa66f6b4c3922329412470e752296e%2Flink-local-link-state-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://330243581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTep4EGj6hSC54ozHujyK%2Fuploads%2Fgit-blob-d51df08d197619a2bd830aeaa9621e50feda47fc%2Flink-local-link-state-light.png?alt=media" alt="Style sources menu with the local-link state" width="240"></picture><figcaption></figcaption></figure>

Webstudio applies the Local Link state when the link's path and query string match the current URL. The part after `#` controls which links match:

* At `/faq`, links to `/faq`, `/faq#one`, and `/faq#two` all match.
* At `/faq#one`, links to `/faq` and `/faq#one` match, but `/faq#two` does not.

This differs from the [CSS `:local-link` definition](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:local-link), which ignores the part after `#` in both URLs. Webstudio keeps it when the current URL points to a section, so a different section link does not get the Local Link state. When the current URL has no `#`, multiple section links can be highlighted at once.

By default, Webstudio marks every matching link with `aria-current="page"`, including section links. You can set a different `aria-current` value on a link when needed.

## Related

* [Button](https://docs.webstudio.is/university/core-components/button.md) – Clickable action buttons
* [Element](https://docs.webstudio.is/university/core-components/element.md) – Generic HTML elements
* [Navigation Menu](https://docs.webstudio.is/university/radix/navigation-menu.md) – Navigation with dropdowns


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.webstudio.is/university/core-components/link.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
