Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML

              
                <section id="heading-container">
  <h1 id="heading-one">Heading 1</h1>
  <h1 id="heading-two">Heading 2</h1>
</section>

<section id="span-container">
  <span>Inline Element</span>
  <span id="adjust-margin">Inline Element</span>
</section>

<section id="container">
  <div id="content-wrapper">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  </div>
</section>
              
            
!

CSS

              
                #heading-container, #span-container{
  width: 500px;
  margin: 0 auto;
}

h1 {
  text-align: center;
  display: inline-block;
  background-color: #FAF0E6;
  width: 500px;
/*height: 100px;*/
  padding: 20px;
  border-style: solid;
  border-radius: 6px;
}

/*------------------------*/

/* Un-comment both of these selectors below to see what happens to the elements. To use a shortcut in doing this, highlight both selectors and use cmd + k if you are on mac. */

/* #heading-one{
  margin-bottom: 0;
}

#heading-two{
  margin-top: 0;
} */

/* This is called Margin Collapsing. Originally the two elements shared margin space. Heading 1 had bottom margin that overlapped with heading 2's top margin. Setting their margins to 0 will collapse the margins. */

/*------------------------*/

span{
  border-style: solid;
  border-radius: 6px;
  background-color: #F5F5DC;
/*   font-size: 20px; */
/*Why doesn't margin-top work on inline elements?
  
  margin-top: 2px; */
  
  /* margin ONLY works horizontally on inline elements. So just inputting '2px' affects the horizontal left and right margin only. */
  
  /* To change this, we would need to change the display style to inline-block. Un-comment the code below to see how it affects the span elements. */
  
/*   margin: 5px 0;
  padding: 20px;
  display: inline-block;
  text-align: center;
  width: 500px; */
  
/* What if you wanted no margin between the inline elements? Change the margin to 0 and see what happens. You see how there is a space between the two spans? Why? We removed the margin, so why is there still a space?
  
  This is actually because of the spans above in the HTML. They are on two separate lines. Put both span element on the same line and the margin will disappear. There is another way to get around this issue without changing the HTML, and that would be to use negative margin values.
  */
}

/* #adjust-margin{
  margin-left: -6px;
} 
*/

/* This only works with margin. Padding doesn't accept negative values. */

/* Instead of using negative margin values, you can change the font-size of the spans parent element. Un-comment this code below for the span-container, comment out the margin property in the span selector, then un-comment the font-size in the span selector.*/

/* #span-container{
  font-size: 0;
} */

/*------------------------*/

/* If you would like to set the whole background of a section to a different color but not just the children elements, make the background color of the parent element a certain color, then place another div inside of the section like this below: */

#container{
  background-color: lightBlue;
  margin-top: 20px; /* This spaces this section lower than the inline elements so that they do not overlap */
}

/* The div #content-wrapper has no semantic meaning, it is just used for styling purposes. */

#content-wrapper{
  padding: 10px;
  width: 500px;
  margin: 0 auto; /* margin here adjusts the div to the center of the page. It doesn't align the text to the center, so we have to use text-align: center; */
  text-align:left;
}
              
            
!

JS

              
                
              
            
!
999px

Console