Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


              <h2>Understanding the CSS box-sizing property values</h2>
<div class="grid-container">
   <div id="div1" class="container div-1">
      <div><strong>box-sizing: content-box</strong>      
      <div class="info"></div>

      By default <code>box-sizing: content-box</code> is active. This means that an element's assigned  width applies only to its content. Any padding and border widths added increase the overall element width. The width of blue box's to the left is set to 400px, but its padding and border widths make the total width of the element 426px. This can be a frustrating "feature" when desigining UIs. 


<div class="grid-container">
   <div class="container div-2">
      <div><strong>box-sizing: border-box</strong>
      <div class="info"></div>
      CSS3 introduced the <code>box-sizing: border-box</code> property. When this property is active an element's specified width is guaranteed to include any padding and border width assigned.    The width of blue box's to the left is set to 400px and that width includes its padding and border widths--making its total width be exactly as specified, 400px. Most CSS resets and CSS frameworks assign this property. <code>box-sizing: border-box</code> is available <a href="">on virtually every browser.</a> 



              body {
  font-family: Sans-Serif;

.grid-container {
   display: grid;
   grid-template-columns: 450px auto;
   justify-items: start;

.container {
   border: 8px solid red;
   padding: 5px;
   background-color: blue;
   width: 400px;
   color: #fff;

.div-1 {
   /* This is the default  */
   box-sizing: content-box;      

.div-2 {
   box-sizing: border-box;      


              const removeNonNumericChars = function(value) {
   return parseInt(value.replace(/\D/g,''), 10);

const getWidthHeight = function(element) {
   let outerWidth = element.offsetWidth;   
   let height = element.offsetHeight;   
   let info = element.querySelector('.info');   
   let innerWidth = parseInt(element.clientWidth,10);
   let paddingLeft = window.getComputedStyle(element, null).getPropertyValue('padding-left');
   let paddingRight = window.getComputedStyle(element, null).getPropertyValue('padding-right');
   let borderLeft = window.getComputedStyle(element, null).getPropertyValue('border-left-width');
   let borderRight = window.getComputedStyle(element, null).getPropertyValue('border-right-width');
   let contentWidth = outerWidth - 
                      removeNonNumericChars(paddingLeft) - 
                      removeNonNumericChars(paddingRight) - 
                      removeNonNumericChars(borderLeft) -
   info.innerHTML = `outer width: ${outerWidth} <br>\
                     inner width ${innerWidth} <br>\ 
                     content-only width: ${contentWidth}<br>\
                     padding width left: ${paddingLeft}<br>\
                     padding width right: ${paddingRight}<br>\
                     border width left: ${borderLeft}<br>\
                     border width right: ${borderRight}<br>`;