34 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Sold between 100 and 1 000 dollars
  • United States
ChordsofLife says

What would be a situation where someone would want to use something like

p.red { }

vs

.red {}

?

2016 posts Review Manager
  • Envato Staff
  • Has been a member for 5-6 years
  • Attended a Community Meetup
  • Australia
  • Beta Tester
  • Contributed a Blog Post
  • Contributed a Tutorial to a Tuts+ Site
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Sold between 5 000 and 10 000 dollars
+7 more
jremick Staff says

When you only want to select paragraphs with the red class vs selecting all elements with the red class. It’s just a matter of being more specific in your selection.

322 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 7-8 years
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
  • United States
  • Won a Competition
shadow66142000 says

Well you could be using ”.red” throughout the site but would like your paragraphs to look a little different than the rest. “p.red” is more precise and will only target a paragraph tag with the class of “red”.
.red {color: red}
p.red {color: #aa0101}

204 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 and 100 dollars
  • United States
parajuli says

p.red is being SPECIFIC , it means only things inside the red class IN the p tag

however..

.red means anything which has a class of red

5 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 10 000 and 50 000 dollars
  • United States
Sirat says

Already well answered. Couldn’t have said it better. :)

by
by
by
by
by
by