Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help3403


This forum is provided to promote discussion amongst students enrolled in Agile Web Development (CITS3403).
 
Options:
RSS cloud
Jump to:

CSS inherit

2 of 419 articles shown, currently no other people reading this forum.
photo
From: ANONYMOUS
Date: Sun 15th Mar 2020, 1:12pm
Actions: 
        Login-to-reply

 

Hi I wanted some clarification on inherit in CSS.

e.g 
color: inherit; // As far as I understand, this will inherit from its Parent Element.

Q:
1. Does it inherit from IMMEDIATE Parent Element?
2. If so, How can I "inherit" from Non-Immediate Parent Elements?

Thanks in Advance
Hadi

CSS inherit

photo
From: Haolin W.
Date: Sun 15th Mar 2020, 5:26pm
Actions: 
        Login-to-reply

 

Hey. Yes you're correct. The inherit property applies the property from the immediate 
parent. As for your other question, I'm not exactly sure what you mean. Do you mean 
inheriting from grandparent/great-grandparent elements? If that's the case, CSS already 
does that.

Take this example. https://puu.sh/FkN8V.png
This has a text colour of red applied on the grand parent element. However, all following 
elements will inherit the red text unless specified otherwise. https://puu.sh/FkNaB.png

The standard inherit example is best visualised when you try to use anchor tags (<a>) to 
redirect to other areas, where the link will always have the blue hyperlink colour. Using 
inheritance removes that colour.
This Page


Program written by: [email protected]
Feedback welcome
Last modified: 11:27am Sep 21 2020