Creating cascading Heading tags with CSS sibling selectors - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:element sibling

Description

Creating cascading Heading tags with CSS sibling selectors

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">
html body h1 {
   margin-left:0em;
   color:Chartreuse;
}

h1~*:not(h1) {<!-- w w  w  . j a  v  a 2s.c  om-->
   margin-left:2em;
   color:yellow;
}

h2~*:not(h2) {
   margin-left:3em;
   color:blue;
}
</style> 
 </head> 
 <body> 
  <h1>Lorem ips</h1> 
  <h2>Lorem ipsum</h2> 
  <p>Lorem ipsum dol</p> 
  <p>Lorem ipsum dol</p> 
  <p>Lorem ipsum dol</p> 
  <h2>Lorem ipsum</h2> 
  <p>Lorem ipsum dol</p> 
  <p>Lorem ipsum dol</p> 
  <p>Lorem ipsum dol</p> 
  <h1>Lorem ipsum </h1> 
  <h2>Lorem ipsum</h2> 
  <p>Lorem ipsum dol</p> 
  <p>Lorem ipsum dol</p> 
  <p>Lorem ipsum dol</p> 
  <h2>Lorem ipsum</h2> 
  <p>Lorem ipsum dol</p> 
  <p>Lorem ipsum dol</p> 
  <p>Lorem ipsum dol</p>  
 </body>
</html>

Related Tutorials