HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Anchor name Property

Anchor Object Reference Anchor Object

Definition and Usage

The name property sets or returns the value of the name attribute of a link.

The name attribute specifies the name of an anchor, and is used to create a bookmark inside a document.

Syntax

Set the name property:

anchorObject.name="name"

Return the name property:

anchorObject.name

Value Description
name Specifies the name of the anchor


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The name property is supported in all major browsers.


Example

Example

Return the name of a specific anchor:

<html>
<body>

<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p>

<h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p>

<h2><a id="c3" name="C3">Chapter 3</a></h2>
<p>This chapter explains ba bla bla</p>

<script>
document.write("Return name of anchor: ");
document.write(document.getElementById("c3").name);
</script>

</body>
</html>

The output of the code above will be:

C3

Try it yourself »


Anchor Object Reference Anchor Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE