+ 16

Why "id" is global attribute?

6th Mar 2019, 2:56 AM
AÍąJ
AÍąJ - avatar
10 Respostas
+ 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.😉😉🙌🙋🙌
6th Mar 2019, 6:37 AM
Asmit joy
Asmit joy - avatar
+ 8
AJ Anant , I think it is because of ID defines a unique identifier
6th Mar 2019, 3:26 AM
Saed Osman Ibrahim
Saed Osman Ibrahim - avatar
+ 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'?
7th Mar 2019, 6:38 AM
Sonic
Sonic - avatar
+ 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! 😊
6th Mar 2019, 11:27 AM
Janning⭐
Janning⭐ - avatar
+ 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
7th Mar 2019, 1:59 PM
Janning⭐
Janning⭐ - avatar
+ 4
This is because it can be used with any HTML element to uniquely identify the element.
6th Mar 2019, 9:51 AM
KING
KING - avatar
+ 3
Because all html elements can have an id attribute.
6th Mar 2019, 8:40 AM
Shahram
Shahram - avatar
+ 2
because it is confusing to use one Id for double or multiple elements in Javascript. Hope that answer the question.
6th Apr 2019, 12:31 PM
MusabYK
MusabYK - avatar
+ 1
Id tags can be used in all elements And the value in an element has to be unique
16th Mar 2019, 7:23 AM
Alpha
Alpha - avatar