<head>
          <style type="text/css">
		div{background-color: blue !important;}
	  </style>
	</head>
	<body>
	  <div style="width: 100px;height: 100px;background-color: red;"></div>
	</body>    

  一般来说内联样式的优先级权重大于内嵌样式

直接在div标签上写style属性叫做内联样式  而在head标签里定义的style标签里写的叫内嵌   而通过css文件加载的叫外联

上面的代码可以看出,使用了!important属性后,内嵌样式高于了内联样式

 

当然,如果你在内联样式又加一个

background-color: red !important;  那么内联又高于了内嵌
posted on 2018-11-14 17:43  YKing_匆  阅读(290)  评论(0编辑  收藏  举报