vendredi 7 mars 2014

CSS precedence based on parent div


Vote count:

0




If you view the following code in a browser the link appears red. I would expect it to be green because the secondary div is nested inside the primary div. It appears the color is determined by the order of the elements in the css file. If I move .secondary after .primary the link is green.



<html lang="en" xmlns="http://ift.tt/lH0Osb">
<head>
<meta charset="utf-8" />
<title></title>
<style>
.secondary a {
color: green;
}

.primary a {
color: red;
}
</style>
</head>
<body>
<div class="primary">
<div class="secondary">
<a href="http://www.google.com">test</a>
</div>
</div>
</body>
</html>


Other than changing the order in the file how can I make the link respect the color from its parent div?



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire