34 posts
  • 7 Years of Membership
  • Author Level 2
  • Collector Level 2
  • Exclusive Author
+2 more
ChordsofLife
says

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

p.red { }

vs

.red {}

?

2036 posts Quality Manager
  • Affiliate Level 2
  • Author Level 4
  • Collector Level 4
  • Envato Team
+14 more
jremick
Envato team
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.

323 posts
  • 8 Years of Membership
  • Affiliate Level 2
  • Author Level 5
  • Collector Level 4
+7 more
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
  • 6 Years of Membership
  • Author Level 1
  • Collector Level 1
  • Exclusive Author
+1 more
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
  • 6 Years of Membership
  • Author Level 5
  • Collector Level 1
  • Exclusive Author
+2 more
Sirat
says

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

by
by
by
by
by
by