Forum Moderators: not2easy
<div id="header">
<ul>
<li>item a</li>
<li>item b</li>
</ul>
<div id="site_nav">
<ul>
<li>item a</li>
<li>item b</li>
</ul>
</div>
</div>
and if I have some css:
#header ul{
border:1px solid blue;}
#site_nav ul{
border:1px solid red;}
So there's two unordered lists here: one directly inside of #header, and another that's inside of #site_nav - which is also inside of #header.
These both have the same CSS specificity score (101, right?) So why is it the case, what rule is being employed, that makes it so the declaration for #header ul overrides the more localized declaration of #site_nav ul? Why does the border render as blue?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
#header ul {
border:1px solid blue;
}
#site_nav ul {
border:1px solid red;
}
</style>
</head>
<body>
<div id="header">
<ul>
<li>item a</li>
<li>item b</li>
</ul>
<div id="site_nav">
<ul>
<li>item a</li>
<li>item b</li>
</ul>
</div>
</div>
</body>
</html>