MDN self-hosted library · e01.org

HTMLAnchorElement: text property

HTML DOM

Open notebook · 3 cells web-api-instance-property upstream source

HTML DOM

The text property of the HTMLAnchorElement represents the text inside the element. This property represents the same information as Node.textContent.

Value

A string.

Example

<a id="exampleLink" href="https://example.com">Example Link</a>
<p class="text"></p>
#exampleLink {
  font-size: 1.5rem;
}
const anchorElement = document.getElementById("exampleLink");
const pTag = document.querySelector(".text");
pTag.textContent = `Text property: ${anchorElement.text}`;

Result

100

Specifications

Browser compatibility

See also

  • HTMLScriptElement.text property
  • HTMLOptionElement.text property