Create selector to take precedence over selectors on parent elements - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:element parent child

Description

Create selector to take precedence over selectors on parent elements

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
a {<!--  w  w  w. ja v a  2  s  .  c o m-->
   border:2px solid Chartreuse;
   padding:21px;
   display:block;
}

a.gray {
   background-color:yellow;
}

a:hover {
   background-color:blue;
}

.container a {
   background-color:pink;
}

a.pink {
   background-color:OrangeRed;
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <a>Lorem </a> 
   <a class="pink">Lore</a> 
   <a class="gray">Lore</a> 
  </div>  
 </body>
</html>

Related Tutorials