CSS CSS Basics Understanding Values and Units Percentages

Nick Ars
Nick Ars
5,341 Points

Can we add a common class for .primary-content and .secondary-content?

instead of writing: .primary-contetnt,
.secondary-content { }

2 Answers

Owa Aquino
Owa Aquino
19,277 Points

Hi Nick!

Yes we can, in the video Guil makes the classes different because they have different styling rule that are unique on that class.

.primary-content{
 //styles that specific only for primary class elements
}

.secondary-content{
//styles that specific only for secondary class elements
}

then you can also create a style that primary and secondary-content can share (using comma)

.primary-content,
.socondary-content {
  //shared style rule for primary and secondary
}

Or you could create a new class that you can add to your element (html element that having .primary-content or .secondary-content)

.new-class{
  //style rules for new class
}

you just have to add your .new-class both beside your primary and secondary-content <div> (or element).

<div class="primary-content new-clase">
  //your other html elements
</div

<div class="secondary-content new-class">
  //your other html elements
</div>

Hope this help. Cheers!

Owa

Nick Ars
Nick Ars
5,341 Points

Thank you very much)