Normalize perceived padding on an element with unknown children - HTML CSS CSS Property

HTML CSS examples for CSS Property:padding

Description

Normalize perceived padding on an element with unknown children

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">
p {<!--   w w  w.  ja v a 2  s .c  o  m-->
   margin:0px;
   padding:2em 0 2em;
}

ul {
   margin:2em 0 2em;
}

.box {
   border:3px solid Chartreuse;
   background:yellow;
   padding:0 2em 0 2em;
   margin:2em;
}
</style> 
 </head> 
 <body> 
  <div class="box"> 
   <p>Lorem ipsum dolor sit am</p> 
   <p>Lorem ipsum dolor sit </p> 
  </div> 
  <div class="box"> 
   <ul> 
    <li>Lorem</li> 
    <li>Lorem</li> 
    <li>Lorem</li> 
   </ul> 
  </div> 
  <div class="box"> 
   <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> 
   <p style="margin-bottom:0">Lorem ipsum dolor sit amet, consectetur adipiscing e</p> 
  </div>  
 </body>
</html>

Related Tutorials