0

Inheritance in CSS

<head><style> body{Color:green;} .div{color:Red;} </style> </head> <body> <div class="div"> <p> this is some text</p> </div> </body> Now Why the Paragraph in the Body section uses red color instead of green which is defined as a color for the body section.

22nd Nov 2016, 1:09 AM
Shanmugarajan Kalyanasundarsam
Shanmugarajan Kalyanasundarsam - avatar
2 Answers
+ 2
Divs are separated of the body , the <p> will give the precedence to the div style . And actually this is why we use divs
22nd Nov 2016, 3:19 AM
Amine Karimi
Amine Karimi - avatar
0
Answer is RED. EXPLANATION: Though the body tag is specfied with green color , the p tag in the div section takes the priority of .div(class selector) defined with color:red first.Hence "this is some text" is diplayed in red color...
10th Feb 2022, 8:44 AM
Padmanaban P
Padmanaban P - avatar