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

              
                <header>
  <h1>Best-selling music artists</h1>
</header>

<main>
  <table>
    <thead>
      <tr>
        <th>Artist</th>
        <th>Country/Market</th>
        <th>Period active</th>
        <th>Release year of first charted record</th>
        <th>Genre(s)</th>
        <th>Total certified units</th>
        <th>Claimed sales</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>The Beatles</td>
        <td>United Kingdom</td>
        <td>1960&ndash;1970</td>
        <td>1962</td>
        <td>Rock, Pop</td>
        <td>278.4 million</td>
        <td>600 million</td>
      </tr>
      <tr>
        <td>Elvis Presley</td>
        <td>United States</td>
        <td>1954&ndash;1977</td>
        <td>1954</td>
        <td>Rock and roll, Pop, Country</td>
        <td>225.2 million</td>
        <td>600 million</td>
      </tr>
      <tr>
        <td>Michael Jackson</td>
        <td>United States</td>
        <td>1964&ndash;2009</td>
        <td>1971</td>
        <td>Pop, Rock, Dance, Soul, R&B</td>
        <td>231.8 million</td>
        <td>350 million</td>
      </tr>
      <tr>
        <td>Elton John</td>
        <td>United Kingdom</td>
        <td>1964&ndash;present</td>
        <td>1969</td>
        <td>Pop, Rock</td>
        <td>186.4 million</td>
        <td>300 million</td>
      </tr>
      <tr>
        <td>Madonna</td>
        <td>United States</td>
        <td>1979&ndash;present</td>
        <td>1982</td>
        <td>Pop, Dance, Electronica</td>
        <td>173.6 million</td>
        <td>300 million</td>
      </tr>
    </tbody>
  </table>
</main>

<footer>
  <p>
    <small>Tabular data from <a href="https://en.wikipedia.org/wiki/List_of_best-selling_music_artists#250_million_or_more_records">Wikipedia</a></small>
  </p>
</footer>
              
            
!

CSS

              
                table {
  border-collapse: collapse;
}

th, td {
  padding: .5rem;
  border: 1px solid #999;
  text-align: left;
}
              
            
!

JS

              
                // Get the closest common ancestor of the `td` elements
var $tbody = $("tbody");

// Change the background color of an element
function changeBackgroundColor(element, color) {
  $(element).css("backgroundColor", color);
}

// When a `td` element is clicked,
// change its background color to light blue
$tbody.on("click", "td", function(event) {
  changeBackgroundColor(event.target, "lightblue");
});
              
            
!
999px

Console