What do these two CSS selectors mean?
h1#myItemOne h2
{
background:#0099FF;
color: #A3F4A3;
}
h1.myItemTwo h2
{
background:#0099FF;
color: #A3F4A3;
}
Are these two selectors valid for use?
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.
The first matches an h2 element that is a
childdescendant of an h1 element with the idmyItemOneExample:
The second matches an h2 element that is a
childdescendant of an h1 element with the classmyItemTwoExample:
They are both valid. The major difference is that id should be unique. Class does not have this requirement.
Reference: http://www.w3.org/TR/CSS2/selector.html