I have a div with an ID:
<div id="main">
What’s the correct (or difference) between
div#main {
and
#main {
Regards,
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.
There is a great doco on using efficient CSS selectors, focus on rules with overly qualified selectors:
Instead of just applying the style to an element with id
main, your selector will re-qualify the element by checking whether or not it’s also adiv(in that order). To clarify: css selectors are evaluated right to left, unlike same selector syntax when used in jQuery etc.Re pixelistik’s suggestion that
div#mainis more specific than#main– yes, that is technically correct, however if you have to resort to this to raise a rule’s specificity, chances are the structure of CSS you’re working on is not as thought through as it should be.