I understand element id values should be unique on the same web page. But can you run into problems if you use the same id value across different web pages?
Asked
Active
Viewed 190 times
0
-
what you want to achieve? – Devsi Odedra Oct 01 '20 at 10:59
-
No, ids are unique among each page individually. But what you are doing seems like in future you may run into problem if you loose control of loading of the page components and somehoe allow multiple ids to be rendered on same page. – Abror Abdullaev Oct 01 '20 at 11:00
1 Answers
0
There is no intrinsic issue with reusing IDs across different pages.
It can lead to problems if you have CSS or JS (which is loaded on multiple or all pages) that uses an ID to target an element and it meets a different and unrelated element with the same ID on a different page which should not be targeted by the CSS/JS.
OTOH, if you have a widget which appears on multiple pages which should have that CSS or JS applied to it, using the same ID to identify it on multiple pages is perfectly fine.

Quentin
- 914,110
- 126
- 1,211
- 1,335