HTML元素定义 ID,Class,Style的优先级

#footer{width:500px;height:220px;background-color:Red}
div.footer2{width:500px;height:220px;background-color:gray}
<div id="footer" class="footer2" style="background-color:blue" ></div>

上面的div背景 最终将显示 内联样式style的  blue

如果去掉style属性

<div id="footer" class="footer2" ></div>

将显示  id选择器  的  Red背景色

所以他们的关系是   内联Style>ID >Class;

posted @ 2012-01-14 17:50  正定聚  阅读(1558)  评论(0编辑  收藏  举报