HTML DOM Element id Property

Get the id of the first anchor

Definition and Usage

The id property sets or returns the value of an element's id attribute.

Note

An id should be unique within a page.

See Also

The getElementById() Method

CSS Syntax

CSS #id Selector

Syntax

Return the id property:

element.id

Set the id property:

element.id = id

Property Value

Value Description
id The id of the element.

Return Value

Type Description
StringThe id of the element.

Browser Support

element.id is supported in all browsers:
Chrome IE Edge Firefox Safari Opera
Yes Yes Yes Yes Yes Yes