freginold
freginold

Reputation: 3956

Can you use IDs with HTML head tags?

I think the answer is probably "no," but I wanted to get the opinion of people who know a lot more than me. Can you use the "id" attribute with HTML elements in the head section, such as title or link? The purpose would be to change their values with JavaScript. Thanks in advance.

Upvotes: 3

Views: 1903

Answers (3)

Ryan
Ryan

Reputation: 14649

The id attribute is a Global Attribute

Yes, you can use an id attribute in a head element. Further, here is the full list of Global Attributes and they may be specified on all HTML elements.

  • accesskey
  • class
  • contenteditable
  • dir
  • hidden
  • id
  • lang
  • spellcheck
  • style
  • tabindex
  • title
  • translate

Upvotes: 1

Ben Aubin
Ben Aubin

Reputation: 5657

Yup. Every html element supports an id:

<head id="everyone"/>

Upvotes: 1

Quentin
Quentin

Reputation: 943568

Yes. All HTML elements support the ID attribute.

See the spec:

The following attributes are common to and may be specified on all HTML elements (even those not defined in this specification):

  • id

Upvotes: 15

Related Questions