CSS Syntax Definitions

Please define the following css syntax meanings so that I don’t misinterpret:

.cow .horse .dog { margin: 0px}
.cow, .horse, .dog { margin: 0px}
.cow.horse.dog { margin: 0px}

Thanks

1 Like
  1. A space between means a parent - child relation.
  2. A comma between means another selector, usually on a new line.
  3. A no space or comma in between means a combination of classes. (On the same element.)
2 Likes

Thanks

1 Like
<div class="cow">
   <p class="horse">Some text. <span class="dog">This span has no margin.</span></p>
</div>
<div class="cow">This has no margin.</div>
<div class="horse">This doesn't have a margin either.</div>
<div class="dog">This also has no margin.</div>
<div class="cow horse dog">This has no margin.</div>
3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.