+ 15
Why is ID a global attribute but cannot apply to some elements
12 Réponses
+ 6
Ok
+ 6
JavaScript uses document.getElementsById to find the ID
+ 6
I still don't understand
Maybe it's because I don't have any knowledge about JavaScript
+ 6
Thanks
+ 6
Yes
+ 5
//Its called Global attribute because it can be apply to all html elements
+ 5
OK
+ 4
But in one of the questions in challenging I saw a question which stated whether I'd can be applied to <p>.
+ 4
#Id
+ 2
Just to clarify confusion:
You can use ID on any element you want.
But you can only use it ONCE, if you use it more than once, the styling/JavaScript will only focus on the first/last ID in your HTML code.
A special task for you: Google wether Styling and JavaScript uses your first ID or your last ID in your HTML document.
+ 2
You're close enough :)
So in the end, you should only apply a specific ID Attribute Value to one Element.
Example <p id="Para1"> and <p id="Para2">
Hope this helped you a bit, enjoy!
+ 1
Hector Domingo yup it can be apply on <p> tag