The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> merge 2 css classes in to a 1 class?
CharliePrince
post Nov 14 2020, 05:56 PM
Post #1


Novice
**

Group: Members
Posts: 24
Joined: 7-November 20
From: Saint Louis, MO
Member No.: 27,623



I have two css classes that do the exact same thing, in this case, each of the two classes apply the small-caps font where, the top class is for <div>s and the lower one is for <span>s.

In my css file, is there a way to have only 1 small_caps class that can be used with different html tags?

my css file looks like this
CODE

div.small_caps {
  font-variant: small-caps;  
}

span.small_caps {
  font-variant: small-caps;  
}


My html looks like this
CODE

<div class="small_caps">Machine Automation</div>

<div> <span class="small_caps">Machine</span> Automation</div>


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 14 2020, 06:01 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Hi-hi! tongue.gif

Ditch the element parts of the selectors.

CODE
.small_caps {
  font-variant: small-caps;  
}



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharliePrince
post Nov 14 2020, 06:04 PM
Post #3


Novice
**

Group: Members
Posts: 24
Joined: 7-November 20
From: Saint Louis, MO
Member No.: 27,623




I'm such a knucklehead ha. I swear I tried that and it didn't work but it works now. Thanks again pandy!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 14 2020, 06:10 PM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Only time it wouldn't work is if you have another selector that sets font-variant to something else that overrides this. And it can do that only by higher specificity or cascade precedency.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharliePrince
post Nov 14 2020, 06:27 PM
Post #5


Novice
**

Group: Members
Posts: 24
Joined: 7-November 20
From: Saint Louis, MO
Member No.: 27,623



QUOTE(pandy @ Nov 14 2020, 07:10 PM) *

Only time it wouldn't work is if you have another selector that sets font-variant to something else that overrides this. And it can do that only by higher specificity or cascade precedency.

Excellent info sir, excellent! That (being overridden) must have been what I was doing
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 14 2020, 06:43 PM
Post #6


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Or you simply made a typo.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th April 2024 - 10:37 AM