Skip to main content

Anchor component

Inserts a tiny piece of code that allows you to link to a specific location within a web page.

Component(s) you might want to use with this one:

Guidelines

An anchor is a tiny piece of code that is appended to a hyperlink. The anchor allows you to link to a specific location on the page instead of the top. If a web page URL is like an apartment building address, then the anchor is like your apartment number – a specific location within that address. 

Anchor links have 2 parts:

  • the anchor id
  • the link that points to the anchor

Examples & use cases

Part I – add the anchor

  1. Drag the anchor component to the spot on your page.
  2. Give it a simple url-friendly name (lower-case, no spaces). This is the anchor id.
Anchor link component showing icon and text field to input url-safe name

Part II – add the hyperlink

To link to an anchor on the same page:

  • Enter # followed by the anchor id in any hyperlink field, e.g.: #support
Anchor id is entered in the Link field, e.g. #support Linking to an Anchor from the WYSIWYG component
Anchor id is entered in the Link field, e.g. #support Linking to an Anchor from the Button component

To link to an anchor from a different page

  • In any hyperlink field, use the relative path of the destination page followed by .html#[anchor id]
Image shows a highlighted path of a page with the anchor suffix The page will link to the #support anchor id on ../web/design/component-documentation-2021/anchor.html

Dos (optional section)

  • When your link is set, test it. You may have to activate the page to ensure your anchor functions properly.
  • Hyperlinks make a promise to your user; ensure the context of your content is clear so that someone landing at that anchor (perhaps mid-page) clearly understands where they are.

Don'ts (optional section)

  • Don't use same-page anchors on relatively short pages that are simple to navigate.
  • In general, avoid linking to an Anchor on another page because the change in context may confuse the visitor.

Helpful tips & "gotchas"

If your anchor does not work, check that the id matches.

Training

Advanced training

Need support?

The Web team is here to help.

© Concordia University