What is used with an anchor < a > element to set a bookmark for an area on the current page?

Abstract

Create an anchor in a rich text field and link to it from the current page or another page.

An anchor is an HTML code that is used as a bookmark to create a link to a particular section within a page. For example, it could be a Back to top link that takes the user to the top of the current page, or it could be a link to a section in the middle of another page.

In Content, you can use the HTML editor to create an anchor in a rich text field, and then you can include the anchor ID when you create a link.

To create an anchor:

  1. In Content, navigate to the item where you want to insert an anchor.

  2. Click Edit content for the rich text field where you want to insert an anchor.

  3. Click the HTML editor tab.

  4. In the HTML code, insert the anchor using the format id=“anchor-name”. For example, the following HTML code assigns the anchor name <MyAnchor> to a paragraph:

    <h2>Introduction</h2> <p>This is paragraph 1</p> <p id="MyAnchor">This is the paragraph I want to link to.</p>
  5. Click Save and close.

To link to an anchor on the same page as the link:

  1. In Content, in the rich text editor, select the text that you want to format as a link.

  2. In the rich text editor panel, click the Create or edit hyperlink icon

    What is used with an anchor < a > element to set a bookmark for an area on the current page?
    .

  3. In the Add link panel, in the Link type field, select External.

  4. In the URL field, enter #<anchor-name>.

    What is used with an anchor < a > element to set a bookmark for an area on the current page?

  5. Click Save link.

Abstract

Use an anchor to link to a particular section within a page.

An anchor is an HTML code that is used as a bookmark to create a link to a particular section within a page. For example, it could be a Back to top link that takes the user to the top of the current page.

In Rich Text fields, you can use the Hyperlink Manager to create an anchor in your text, and then to create the link to your anchor.

Note

In Word fields, you cannot access the Hyperlink Manager. Instead, you must use the Hyperlink functionality within Microsoft Word.

To create an anchor:

  1. In the Experience Editor or the Content Editor, navigate to the item where you want to insert an anchor.

  2. Open the Rich Text Editor and select the text or image that you want make an anchor.

  3. Click the Hyperlink Manager 

    What is used with an anchor < a > element to set a bookmark for an area on the current page?
    .

  4. In the Hyperlink Manager dialog, click the Anchor tab and in the Name field, enter a unique name for the anchor.

    What is used with an anchor < a > element to set a bookmark for an area on the current page?

  5. Click OK.

  6. To create a link to this anchor, you create a new link with the Hyperlink Manager. On the Hyperlink tab, in the Existing Anchor field, choose the anchor you created and click OK.

    What is used with an anchor < a > element to set a bookmark for an area on the current page?

    Note

    If the anchor is in a different Rich Text field from the link, then you will not be able to select the anchor in the Existing Anchor field. To link to an anchor in another Rich Text field on the page, in the URL field, enter #[anchor name] and click OK.

    What is used with an anchor < a > element to set a bookmark for an area on the current page?

Macro options (parameters)

Where the parameter name used in Confluence storage format or wikimarkup is different to the label used in the macro browser, it will be listed below in brackets (example).

Parameter

Default

Description

Anchor Name

None

This is the anchor name that you will use when creating the link.

  • The anchor name can include spaces. Confluence will remove the spaces automatically when building a URL that points to this anchor.
  • The anchor name is case sensitive. You must use the same pattern of upper and lower case letters when creating the link as you used when creating the Anchor macro.

You can link to an anchor from:

  • A page on the same Confluence site. The link may be on the same page as the anchor, another page in the same space, or a page in another space on the same Confluence site.
  • Another web page or another Confluence site, using a specifically formatted URL.

Link to an anchor on the same Confluence site:

  1. Select some text or position your cursor where you want to insert the link
  2. Choose Link in the toolbar or press Ctrl+K
  3. Choose Advanced and enter the anchor name in the Link field, following the format below.

    Anchor locationLink syntax for anchorExamples
    Same page #anchor name

    #bottom

    #important information

    Page in same space page name#anchor name

    My page#bottom

    My page#important information

    Page in different space spacekey:page name#anchor name

    DOC:My page#bottom

    DOC:My page#important information

  4. Enter or modify the Link Text (this is the text that will appear on the page. If this field is left blank, the page name or URL will be used as the link text)
  5. Choose Save

  • Anchor names are case sensitive.
  • Enter page and anchor names with spaces when you link to them in the same Confluence site. A good way to do this is to copy the page title exactly as appears on the page. Don't copy the page URL, as we don't want to include the + symbol).
  • If you're linking to an anchor on a different page that has special characters in its name, where the URL displays a page ID rather than a name, you should still enter the page name when linking to it.

Screenshot: The 'Advanced' option in the link dialog

What is used with an anchor < a > element to set a bookmark for an area on the current page?

Link to an anchor from another web page or another Confluence site:

Use a full URL in the following format:

Link syntax

Examples

http://myconfluence.com/display/spacekey/pagename#pagename-anchorname

http://myconfluence.com/display/DOCS/My+page#Mypage-bottom

http://myconfluence.com/display/DOCS/My+page#Mypage-importantinformation

Notes about the full URL:

  • The page name is repeated in the URL, after the # sign. The second occurrence of the page name is concatenated into a single word, with all spaces removed.
  • There is a single dash (hyphen) between the concatenated page name and the anchor name.
  • The anchor name in the full URL is concatenated into a single word, with all spaces removed.
  • The anchor name is case sensitive.
  • If the page name contains special characters, where the URL displays a page ID rather than a name, the link to an anchor will look more like this http://myconfluence.com/pages/viewpage.action?pageId=54689987#Test-page1!-anchor 
    In this example the page title is Test - Page 1! and the anchor name is anchor.

Notes

  • Table of contents on a page: Consider using the Table of Contents Macro to generate a list of links pointing to the headings on the page. The list of links will appear on the page, and will be automatically updated each time someone changes the wording of a heading.
  • Linking to headings: You can link directly to the headings of a page. See Links. However, if someone changes the wording of a heading, those direct links will be broken. Use the Anchor macro to ensure a lasting link within the body of a page.
  • Site welcome message: If you are adding an anchor to a page that you are using in the site welcome message, you can only link to that anchor from another page. Internal links within that page will not work.
  • Templates: When you are previewing a template, a link to an anchor is displayed as a 'broken' link. However, when you create a page using the template the resulting page will have the correct link.

How do you use anchor bookmarks?

Type the anchor name in the pop-up box..
Type in the text for the link if you have not already done so (such as, “Back to top”)..
Highlight the link text..
Click , Insert Hyperlink..
In Insert/Edit Link window, select an Anchor with the down arrow..
Click Insert ..

What is an on page anchor in HTML?

An anchor is a piece of text which marks the beginning and/or the end of a hypertext link. The text between the opening tag and the closing tag is either the start or destination (or both) of a link. Attributes of the anchor tag are as follows. HREF. OPTIONAL.

How do I anchor to a specific part of a page?

How to link to a specific part of a page.
Give a title to the text you'd like to link. First, make a title or name to the text you'd like to link on your webpage. ... .
Put the title into an opening HTML anchor link tag. ... .
Insert the anchor tags around the text you want to link to. ... .
Create a hyperlink that leads you to the text..

What is the use of anchor tag in HTML?

The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.