Linking

Amaya

## Creating and changing links and anchors

### Creating a target anchor

A target anchor is a piece of text that is referred to by a link (a source anchor). Before creating a link to a text string, you must first turn it into a target anchor.

To create a target anchor:

1. Select the appropriate text string.
2. Choose Create target from the Links menu or click the button in the Elements tool. The selected text is now a target.

   In the Formatted view, if Views/Show targets is turned on, the target text is preceded by a target icon . In the Links view, icons that identify target anchors are always displayed.

3. When a target anchor is created, Amaya automatically generates the value of the `name` attribute by:
   - Extracting a word longer than 3 characters from the anchor text, or
   - assigning a number.

   In both cases, Amaya guarantees that the generated value is unique within the document. But you can change this value, in the same way as the value of any attribute.

Note: If you want to create a link to the last target anchor you have created, choose Link to previous target from the Links menu.

### Creating a target element

In (X)HTML, any element can be used as a target. A target element is an element with an `id` attribute to which a link can refer (a source anchor). Before creating a link to such an element, you must first turn it into a target element.

To create a target element:

1. Select within the element, then press the `F2` key to select the entire element. The selection path at the bottom of the window may be useful to select the right element.
2. Open the Links menu and select Create target or click the button in the Elements tool. The selected element now has an `id` attribute that identifies it as a target element.

   In the Formatted view, if Views/Show targets is turned on, the target element is preceded by a target icon . In the Links view, icons that identify target elements are always displayed.

3. When a target element is created, Amaya automatically generates the value of the `id` attribute by:
   - Extracting a word longer than 3 characters from the anchor text.
     or
   - assigning a number.

   In both cases, Amaya guarantees that the generated value is valid and unique within the document. But you can change this value, in the same way as the value of any attribute.

Note: You can also directly create the `id` attribute by selecting the element and using the Attributes list. When you enter an attribute value, Amaya checks it for uniqueness, and changes the value if it is already used by another `name` or `id` attribute in the same document.

Note: If you want to create a link to the last target element you have created, choose Link to previous target from the Links menu.

### Creating an external link

To create an anchor that is a link to another document:

1. Select the text for the link you are creating.
2. Click the Link button , or select entry Create or change link in the Links menu, or use the shortcuts `Ctrl-l Ctrl-l`.
   - If the target document is displayed in another window in Amaya, and you want to designate it by clicking, use the Click button, then click anywhere within that window or tab to create the link.
   - If the target document is displayed in another tab and you want to designate it by clicking, use the Click button, then change the current tab and click anywhere within the target document to create the link.
   - If the target document is a local file you can use the Browse button to select it.
   - Else type the URI (like http://www.w3.org) of the target document and then Confirm to create the link.

### Creating an Internal Link

To create a link to a target anchor or target element in the same document or in another document:

1. Select the text for the link you are creating.
2. Click the Link button in the Elements tool, or select entry Create or change link in the Links menu, or use the shortcuts `Ctrl-l Ctrl-l`.
   - If the target is displayed (you may scroll to display it), activate the Click button then click the target icon to create the link.
   - Else type the URI (like #name) of the local target and then Confirm to create the link.

Note: If you have created the target anchor or target element recently, instead of step 2 above, select Link to previous target in the Links menu: the last target you have created will become the target of the new link.

### Copying a target location

The Links/Copy location command registers the location (URI) of the selected target into the system clipboard. If no target is selected, the current document URL is registered. This location can so be pasted into a dialog box or into another external application.

### Changing a link

Use this procedure to change the target of a link without changing its anchor.

To change a link:

1. Click inside the source anchor.
2. Then click the Link button in the Elements tool, or select the entry Create or change link in the Links menu, or use the shortcut `Ctrl-l Ctrl-l`.
3. Select the new target as if you were creating a link.

Note: You can also manually edit the `href` attribute of the anchor either in the Structure view or in the Links view, or use the Attributes tool.

### Removing a link or a larget anchor

The Delete link or target entry in the Links menu removes the anchor enclosing the cursor location.

To use this command, put the selection or the insertion point anywhere within the anchor to be removed (it is not necessary to select the whole anchor), and choose Delete link or target. The anchor is removed, but its content remains.