+ 1
why we use id
4 odpowiedzi
+ 5
We use ID to target specific elements and phrases in CSS. So for example, if we want to target the P element, which is inside a Div inside a Div inside a Div, instead of writing 'div div div p' in the CSS code, we can just write #[NameOfID]. This way, it is much more accurate, easy, quick and avoid mistakes. I hope this helps.
+ 2
JavaScript or CSS needs to know which HTML element to modify or to apply style to. ID is unique and can only be given to one element. Unless you want to style or modify all <p>'s or <h1>'s for instance, sometimes you want to taget just one of them with a specific style, and therfore you give it a unique ID.
+ 1
it it an code which we use for it
+ 1
for fun ... id is a name for select style for that object or any thing .