473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Why does changing parent’s style has no effect in child’s style in css?

12 Nibble

Take this code for example:

Expand|Select|Wrap|Line Numbers
  1.  <div class="super">
  2.         <div class="extra">text</div>
  3.  </div>
  4.  
*

Expand|Select|Wrap|Line Numbers
  1. .extra
  2. {
  3.     background-color: crimson;
  4. }
  5.  
  6. .super{
  7.     background-color: cyan;
  8. }
  9. *
The background color is crimson at last. It’s related to CSS specificity. I’m curious why that’s the case? Why is background-color not inherited here? Or is this a property that never gets inherited? If there was another property that could get inherited, would the result be different?

Nov 1 '22 #1
2 12974
dev7060
636 Expert 512MB
The background color is crimson at last. It’s related to CSS specificity. I’m curious why that’s the case? Why is background-color not inherited here? Or is this a property that never gets inherited? If there was another property that could get inherited, would the result be different?
Some properties are inherited, and some are not. The child element does not inherit background-color.

You may use the inherit setting for such behavior.
Nov 5 '22 #2
richard110
1 Bit
You have to specify the background-color in child's style also. Check the reference for style CSS on the website.
Nov 16 '22 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: oom | last post by:
I am a bit of a newbie when it comes to python, when working with lists today I noticed some very odd behaviour, any suggestions welcome: Python 2.2.3 (#1, Nov 6 2003, 14:12:38) on linux2...
1
by: Xavier Bourguignon | last post by:
Hi I would like to change the style of a frame within itself by clicking a button, is this possible, how is this accomplished? thank you
9
by: bissatch | last post by:
Hi, Is it possible to change the class style of an HTML element using DHTML? For example... <td class="my_class">Text</td> I have used DHTML to change style elements such as backgroundColor...
1
by: Bart | last post by:
Hi, When changing line style from solid to broken the result is devastating on speed. Something that used to take a fraction of a second to draw takes about a minute when line style is changed....
7
by: G Fernandes | last post by:
Is the following an old-style(K&R) function definition or a new style(C89)? int (length, factor, multiple) { /* ... code ... */ return length; }
2
by: Jensen bredal | last post by:
I'am trying to change the style of my LinkButton control . I have a set of five control and i need to hilight the selected one. I want to achive this by setting MyLinkButton.CssClass="newStyle"...
11
by: Mark Rae | last post by:
Hi, Is there any way to modify the style of the button portion of an HtmlInput control? I have a CSS class which I use for all of the buttons to try to make them a little less ugly than the...
1
by: ankit | last post by:
Hello, Please put some light on, What are new style classes and classic style classes in python. The basic differences in them. And How can I decide to choose one.
0
by: jobs | last post by:
Any way to change the style of a button inside a Login Control? Any way to assign a skin id to the control, that impacts a control (like button) inside the control? thanks for any help or...
1
by: ineuw | last post by:
In Firefox 2.0, I successfully changed the border effect of the standard Select box from sunken to a flat image, using the following CSS: select.fonts { border: 1px solid #acacac;} This...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.