- 1

Why we can use same id to different elements in html

like <p id="navbar'> ------ ---- some code.. <\p> <p id="navbar"> --------some code <\p>

28th Aug 2017, 2:29 AM
AMIT KUMAR
AMIT KUMAR - avatar
2 Réponses
+ 3
As you might already know HTML is a markup language and nothing prevent you to type anything you want. The web browser engine will try its best to render it with respect to the DOCTYPE. So what you're doing is entirely possible but you're digging a hole for yourself as id attribute is global and meant to be *unique*.
28th Aug 2017, 3:56 AM
Zephyr Koo
Zephyr Koo - avatar
0
I realised that it's an invalid expression but still we can use it and it works, but I want to know that what possibly could happen if I use it all over my code instead of classes.
28th Aug 2017, 4:57 AM
AMIT KUMAR
AMIT KUMAR - avatar