Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

HTML element: a

The anchor element represents a hyperlink when it has a destination and otherwise remains a position for a potential link.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<a href="destination">link text</a>

Presence of href creates a link matched by :any-link; without it, the element does not navigate or gain link behavior.

The a content model is transparent, but forbids a descendant a, interactive content, and any descendant with specified tabindex.

The target attribute accepts the _blank keyword, which requests a new navigable and normally implies noopener unless rel="opener" explicitly restores the relationship; download, ping, and referrerpolicy alter navigation or downloading.

The example activates #target through click(), waits for hashchange, and compares :any-link matching with an element lacking a destination.

Examples

<!doctype html>
<meta charset="utf-8">
<a id="jump" href="#target">Jump</a>
<a id="placeholder">Reserved</a>
<h2 id="target">Target</h2>
<output id="result"></output>
<script>
const jump = document.querySelector("#jump");
const placeholder = document.querySelector("#placeholder");
addEventListener("hashchange", () => {
  result.textContent = `hash=${location.hash}; linked=${jump.matches(":any-link")}; placeholder=${placeholder.matches(":any-link")}; target=${document.querySelector(location.hash).textContent}`;
}, { once: true });
jump.click();
</script>

Result

hash=#target; linked=true; placeholder=false; target=Target

The result verifies fragment navigation and the missing-destination boundary; it fetches nothing and opens no new context.

Sources