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

  • SEARCH
  • Home
  • 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 7546729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:16:27+00:00 2026-05-30T09:16:27+00:00

I have a bunch of divs which I nest arbitrarily: <div> <div> <div>Apple</div> <div>

  • 0

I have a bunch of divs which I nest arbitrarily:

<div>
  <div>
    <div>Apple</div>
    <div>
      <div>Banana</div>
      <div>Grape</div>
    </div>
  </div>
  <div>Craisin</div>
</div>

I make their contents pink with a rule like this:

div { color: pink; }

I want to be able to add the special class to any of those divs to cancel out the pink rule for it and all of its children. For example, if I add the special class to this div,

<div>
  <div class="special">
    <div>Apple</div>
    <div>
      <div>Banana</div>
      <div>Grape</div>
    </div>
  </div>
  <div>Craisin</div>
</div>

then “Apple,” “Banana,” and “Grape” should no longer be pink.

Can I tweak my rule to only match divs that aren’t nested inside a .special?

I’m not looking for a solution involves writing a rule for .special that cancels out every style defined on div. For example, this is not a good solution even though it works:

.special, .special div { color: black !important; }

My actual styles are more complicated than just changing the color, and there are other rules with selectors like div span which I would also like to disable with the special class.

  • 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-05-30T09:16:28+00:00Added an answer on May 30, 2026 at 9:16 am

    You cannot prevent children/descendants from inheriting inheritable style properties using CSS.

    The style properties for the descendants have to explictly be reset.

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

Sidebar

Related Questions

I have a div .project-container which contains a bunch of divs with set heights
I have an application creating a bunch of divs through a loop. Each div
If I have a container div called #container which has a bunch of .inside
I have a bunch of hidden images on my website. Their container DIVs have
I have a bunch of divs like this: <div class=bear></div> <div class=dog></div> How do
I have a parent div called main. It has a bunch of child divs
I have a parent div, and it houses a bunch of child divs. One
I have a bunch of floated divs and I have a function which checks
The basic idea is that I have a bunch of div's in which each
Let's say I have a bunch of divs which have either left class or

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.