+ 16
Why "id" is global attribute?
9 Antworten
+ 12
The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document).For this "id" is global attribute.
Hope this is helpful for you.😉😉🙌🙋🙌
+ 8
AJ Anant , I think it is because of ID defines a unique identifier
+ 8
So what makes it global? The fact that it can be used for all elements or the fact its value in an element has to be unique within the whole document? Or are both conditions necessary for 'globalness'?
+ 6
🤔
Some of these answers seem tautological.
I think to fully understand why id became a global attribute, you had to be there at the time the decision was made. Maybe some of our older web developers can weigh in on this. In the meantime, here's what I've gathered:
https://www.w3.org/TR/dom/#concept-id
It used to be that id and name had a confusing relationship. I think id may have taken over some functions that name used to have and vice versa.
https://tools.ietf.org/id/draft-ietf-iiir-html-00.txt
So I think that id becoming a global attribute was a side effect of the bigger move to separate concerns between name and id.
I hope this helps! 😊
+ 5
The former, not the latter.
Global attributes are attributes that may be specified on all HTML elements, even those not defined by the HTML standard / language specifications (for example, experimental/vendor-prefixed/browser-specific elements). Here's a handy chart for a visual:
https://html.spec.whatwg.org/#elements-3
+ 4
This is because it can be used with any HTML element to uniquely identify the element.
+ 3
Because all html elements can have an id attribute.
+ 2
because it is confusing to use one Id for double or multiple elements in Javascript. Hope that answer the question.
+ 1
Id tags can be used in all elements
And the value in an element has to be unique