Home > front end >  CSS three major characteristics of inheritance and CSS style weight stack
CSS three major characteristics of inheritance and CSS style weight stack

Time:12-05

Write CSS style h1 nested inside the h2, so h1 and h2 storage there is no inheritance? How to calculate the weights of the style? Such as the following code:
 


<meta charset="UTF-8">
<meta name="viewport" content="width=device - width, initial - scale=1.0" & gt;
CSS weight stack & lt;/title> <br/><style> <br/>The h2 {<br/>Color: blue; <br/>} <br/>H1 h2 {<br/>Color: yellow; <br/>} <br/></style> <br/></head> <br/><body> <br/><br/><H1 & gt; <br/>H1 <br/><The h2 & gt; <br/>H1, h2 <br/></h2 & gt; <br/></h1> <br/><br/></body> <br/></html> <br/></pre> <br/>After the operation effect is as follows: <br/><img SRC="https://img.codepudding.com/202012/174603050211551.png" Alt=""/> <br/>H1, h2 why not yellow??? <br/><p class="article - content rp"> CodePudding user response: </p>H tag cannot be nested, so your h1 h2 {color: yellow} no effect </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/frontend/92184.html" target="_blank" style="color:#999">https//www.codepudding.com/frontend/92184.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/frontend/92183.html'>UML sequence diagram is generated by JS wrote a tool - NutUml</a></div> <div class="detail-arr-right">Next:<a href='/frontend/92185.html'>Questions about the x86 stack space</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=HTML+%28CSS%29' target='_blank'>HTML (CSS)</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>