CSS的优先级别

 <link rel="stylesheet"type="text/css"href="yangshi.css"/>
<style>
 a{color:red;font-size:18px}
.p1{color:blue;font-size:36px}
#o1{color:green;font-size:72px}
</style> 
</head>
 <body>
  <a href="#">dsds</a>
  <a href="#"class="p1">dsds</a><!--看出class大于默认的-->
  <a href="#"id="o1">dsds</a>
  <a href="#"style="color:yellow;font-size:148px">dsds</a>
  <!--以上是样式的不同格式,下面比较优先级-->
  <a href="#"class="p1"id="o1">dsds</a><!--看出id>class-->
  <a href="#"id="o1"style="color:yellow;font-size:148px">dsds</a><!--看出内置样式在以上样式中优先级最大,下面将他们和外部链接的比较-->

 </body>

显示效果

 <link rel="stylesheet"type="text/css"href="yangshi.css"/>

注释掉显示结果和上面的一样。

下面将

<style>
 a{color:red;font-size:18px}
.p1{color:blue;font-size:36px}
#o1{color:green;font-size:72px}
</style> 
注释掉


显示结果




总结就是大体上样式的优先级别是内置style="">id>class>默认>外链接的,对于默认的和外链接的class进行比较,显示的结果为2者皆不是,和id我就不比较了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值