CSS margin avoided in favor of padding - HTML CSS CSS Property

HTML CSS examples for CSS Property:padding

Description

CSS margin avoided in favor of padding

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">
div {<!--  w  ww  .ja v  a  2 s  .c  om-->
   background:lightblue;
   border:11px solid Chartreuse;
}

.fullblue {
   background:blue;
   margin:0;
   padding:0;
   border:none;
   min-height:51px;
}

.fullblue {
   background:blue;
   margin:0;
   padding:0;
   border:none;
   min-height:51px;
}

.nomargin {
   margin:0px;
   padding:11px;
}

.nopadding {
   padding:0px;
   margin:11px;
}
</style> 
 </head> 
 <body> 
  <div class="fullblue"></div> 
  <div class="nomargin">
    Lorem ipsum 
  </div> 
  <div class="fullblue"></div> 
  <div class="nopadding">
    Lorem ipsum 
  </div> 
  <div class="fullblue"></div>  
 </body>
</html>

Related Tutorials