Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


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


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.


Auto Save

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.


  <title>Modernizing legacy web frontends</title>
  <link rel="stylesheet" href="">
  <link rel="stylesheet" href="">
  <script type="text/javascript" src=""></script>
  <script type="text/javascript" src="app.js"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- container that contains the rendered web application -->
  <div id="app" class="container">
    <div id="heroList" class="row"></div>
    <div id="heroDetail" class="row" style="display: none;"></div>




                "use strict";
// this example is part of a blog post:
// for demo purposes the data is embedded, usually this would be the result of an ajax fetch or similar
var heroData = [
  { name: "Superman", secretIdentity: "Clark Kent", firstAppearance: "1932", image: ""},
  { name: "Batman", secretIdentity: "Bruce Wayne", firstAppearance: "1939", image: ""},
  { name: "Flash", secretIdentity: "Barry Allen", firstAppearance: "1956", image: ""},
  { name: "Green Lantern", secretIdentity: "Hal Jordan", firstAppearance: "1959", image: ""},
  { name: "Hulk", secretIdentity: "Robert Bruce Banner", firstAppearance: "1962", image: ""},
  { name: "Spider-Man", secretIdentity: "Peter Parker", firstAppearance: "1962", image: ""},
  { name: "Iron Man", secretIdentity: "Tony Stark", firstAppearance: "1963", image: ""},
  { name: "Wolverine", secretIdentity: "James Howlett", firstAppearance: "1974", image: ""}

// bootstrap web frontend
function init(){

// renders the list of superheroes
function renderHeroes() {
  var heroList = $("#heroList");
  var table = $("<table />").addClass("u-full-width");
  table.append($("<thead><tr><th>Name</th><th>Secret Identity</th><th>Details</th></tr></thead>"));
  var tableBody = $("<tbody />");
  for (var index = 0; index < heroData.length; index++){
    tableBody.append(buildHero(heroData[index], index));


// used by function renderHeroes to create the jQuery representation of a superhero
function buildHero(item, index) {
  var tableRow = $("<tr />");
  var nameElem = $("<td />").html(;
  var secretIdentityElem = $("<td />").html(item.secretIdentity);
  var detailLink = $("<a />").attr("href", "#").html("Show Details").click({index: index}, showDetail);
  var showDetailElem = $("<td />").append(detailLink);

  return tableRow;

// renders the detail view of a hero, event contains the index of the selected hero
function showDetail(event) {
  var hero = heroData[];
  var detail = $("#heroDetail");
  var image = $("<img />").attr("src", hero.image).css("width", "150px").css("float", "right");
  var title = $("<h1 />").html("Details of " +;
  var description = $("<p />").html("The secret identity of " + + " is " + 
    hero.secretIdentity + " and he first appeared in a comic in the year " + hero.firstAppearance + ".");
  var button = $("<a />").addClass("button").attr("href", "#").html("Show all heroes").click(showHeroes);

function showHeroes(event) {

// call init function when the page is loaded
$( init );