## Linking

### 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. Click and drag to select the appropriate text string.

2. Choose Create Target from the Links menu. The selected text is now a target.

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

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

     or

   - Generating a label.

   In both cases, Amaya guarantees that the generated value is unique within the document.

### Creating a Target Element

In HTML 4.0, an element can be used as a link target. A target element is a typed element with an `ID` attribute to which the link refers (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. Click and drag to select a character string within the element, then press the `F2` key to select the entire element.

2. Open the Links menu and select Create Target. The selected element now has an ID attribute that identifies it as a target element. Amaya automatically generates a unique `ID` value.

   In Formatted view, if Show Targets is turned on, the target element is preceded by an icon . In the Links view, icons that identify target anchors are always displayed.

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

     or

   - Generating a label.

   In both cases, Amaya guarantees that the generated value is valid and unique within the document.

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.

### Creating an External Link

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

1. Select to select (by click and drag or by keyboard) the text for the link you are creating.

2. Click the Link button ,select the entry "Create or change link" in the Links menu, use the shortcuts `Ctrl l Ctrl l`.
   - If the target document is displayed in another Amaya window and you want to select it by click, click the Click button then click anywhere within that window to create the link.
   - If the target document is displayed in another tab and you want to select it by click, click 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:

1. Select to select (by click and drag or by keyboard) the text for the link you are creating.

2. Click the Link button , select the entry "Create or change link" in the Links menu, use the shortcuts `Ctrl l Ctrl l`.
   - If the target is displayed (you may scroll to display it), click 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.

### 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 anchor.
2. Then click the Link button , select the entry "Create or change link" in the Links menu, use the shortcuts `Ctrl l Ctrl l`.
3. Select the new link target like if you are 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 list.

### Removing a Link or a Target Anchor

The Delete Anchor option on 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's not necessary to select the whole anchor), and choose Delete Anchor. The anchor is removed, but its content remains.