+ 1

why we use id

5th Jul 2016, 3:25 PM
Rezaul Karim
Rezaul Karim - avatar
4 Answers
+ 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.
5th Jul 2016, 5:34 PM
Shayan Ali
Shayan Ali - avatar
+ 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.
5th Jul 2016, 5:41 PM
ZinC
ZinC - avatar
+ 1
it it an code which we use for it
14th Jul 2016, 4:15 AM
amol devakate
amol devakate - avatar
+ 1
for fun ... id is a name for select style for that object or any thing .
12th Nov 2016, 2:29 PM
Mim masoumi
Mim masoumi - avatar