0

Id function

why do I need to use the id attribute

7th Sep 2024, 5:41 PM
Haleluya Tegegne
Haleluya Tegegne - avatar
2 ответов
+ 3
You do not need to use it.
7th Sep 2024, 5:46 PM
Lisa
Lisa - avatar
0
Haleluya Tegegne you can write html without using the id attribute. But it makes selecting elements harder if you want to add Javascript to it. Selecting by id is the easiest way to manipulate DOM elements with Javascript. You also need id if you want to link one part of your page to another. href="#yourid" Also, connecting labels with form elements is done through id. You don't have to add it to every element. Only add it to those that needs it.
8th Sep 2024, 12:35 AM
Bob_Li
Bob_Li - avatar