Timeline for element style declared twice in css but css is not appling the stlye declared at last why is it so?
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 18, 2023 at 17:31 | comment | added | ShivBalaji | Thanks for your timely response now i am totally clear. | |
Mar 17, 2023 at 9:22 | comment | added | qrsngky |
The nav{ font-size:18px } targets the <nav> tag, not the <p> tag. If p has its own specific font-size: 22px , it won't inherit from the parent (nav ). Even if you give the parent a class and an id and target it like nav.specialClass#myId , the p will use its own style, unless you use e.g. p{ font-size: inherit}
|
|
Mar 17, 2023 at 9:20 | comment | added | Christian Vincenzo Traina | Also, keep in mind that rarely the order of rules matter in CSS. There are some cases but they are residual and unwanted | |
Mar 17, 2023 at 9:19 | comment | added | Christian Vincenzo Traina |
p is a child of nav , so its specificity will be higher. The solution depends on your code and what you want. Why did you add font-size: 22px; if you don't want it to be applied?
|
|
Mar 17, 2023 at 9:18 | comment | added | Andrii Stropalov | No, style for p element has more weight, so it is 22px | |
Mar 17, 2023 at 9:17 | history | edited | Christian Vincenzo Traina | CC BY-SA 4.0 |
added 8 characters in body
|
S Mar 17, 2023 at 9:13 | review | First questions | |||
Mar 17, 2023 at 22:34 | |||||
S Mar 17, 2023 at 9:13 | history | asked | ShivBalaji | CC BY-SA 4.0 | created from wizard |