Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7952579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:54:10+00:00 2026-06-04T02:54:10+00:00

You may have multiple classes on an element separated by a space: <div class=header

  • 0

You may have multiple classes on an element separated by a space:

<div class="header contaminated">...</div>

and you can target that div using .header.contaminated selector.

That’s fine when both classes are directly applied to an element. i want to target an element with CSS that has both styles, but one style comes from the parent:

Example

<div class="contaminated">
  <div class="header">...</div>
</div>

Normally i want to style a header as blue:

.header { background-color:  #99FFFF; }

But if a div is contaminated then i color the entire background red:

.contaminated { background-color: Pink; }
.contaminated.header { background-color: HotPink; }

Except i don’t think the css selector syntax .contaminated.header is valid for “inherited” styles.

Note: The reason i don’t think it’s valid is because it doesn’t work

Is it possible to target an element with CSS if it only contains two classes, and some of the classes are “inherited” ?

jsFiddle sandbox

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:54:12+00:00Added an answer on June 4, 2026 at 2:54 am

    This is basic CSS – separate the class names by a space, that implies/applies the cascade:

    .contaminated .header { ... }
    

    Anything wrong with that?

    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As you probably already know, you may have multiple classes on elements separated by
Objective: In support of a Windows Service that may have multiple instances on a
I have a wrapper class for log4net to log across multiple classes and assemblies
A single interface may also have multiple IPv6 addresses of any type(unicast, anycast, and
Is it possible to calculate the mean of multiple arrays, when they may have
You may have heard of PawSense , a Windows-only utility that prevents keystrokes from
Sorry for the bad question title. Let's say that I have DateRange class that
I have multiple C# projects in a Visual Studio solution right now that will
I have a control circuit which has multiple settings and may have any number
I have a few separate application projects (EARs) with multiple EJBs that I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.