I understand that there is a *.className selector since there can be multiple html elements with class=className.
But for the ID attribute which should be unique, why does *# exist and when do we use it?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just because IDs are supposed to be unique doesn’t mean they are. You can create multiple elements with the same ID, but you shouldn’t. CSS doesn’t care anyway, lack of uniqueness would just screw with Javascript. For example, if you have this:
Then
jQuery('#blah')returns[ div#blah ], whereasjQuery('*#blah')returns[ div#blah, div#blah, div#blah, div#blah ].jsFiddle Demo