1

I've a div called #descr-two and a h2 and p. In css code two rules are used:

#descr-two h2 {color: #323232;}
#descr-two p {color: #323232;}  

It works, but my goal is a clean and compact code, this code doesn't work:

#descr-two h2, p {color: #323232;}

Why? Where is the error? Thanks.

2
  • You Need a # before descr-two in the CSS and in the HTML you should use it like id="descr-two". Commented Feb 7, 2017 at 10:05
  • Your rule will select all p tags you need to include the id identifier #descr-two h2, #descr-two p. Commented Feb 7, 2017 at 10:06

3 Answers 3

1

Add the #descr-tw identifier also for the p selector

#descr-two h2, #descr-two p {color: #323232;}
Sign up to request clarification or add additional context in comments.

Comments

0

supposing this descr-two is a name not an id use this:

descr-two h2, descr-two p {color: #323232;}

if it is an id you should include '#':

#descr-two h2, #descr-two p {color: #323232;}

Comments

0
#descr-two h2, #descr-two p {color: #323232;}

1 Comment

While this code snippet may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.