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 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.



Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO


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.


Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:


Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO


                <div id='myTest'>
    <div class='help-link'>
        <a href='' target='_blank' rel='noreferrer'>Link to QUnit API</a>
    <div id='qunit'></div>
    <div id='qunit-fixture'></div>

<div id='myPage'>
    <div data-test-my-instructions id='myInstructions'>
        You can submit the form to add a table row.

    <div id='myContainer'>
        <table data-test-my-table id='myTable'>

            <tbody id='myTableBody'>
                <!-- Will be dynamically generated -->

        <form data-test-my-form id='myForm'>
            <fieldset class='form-fieldset'>
                <legend>Primary Information</legend>

                <p data-test-my-form-item='name' class='form-item'>
                    <label for='name'>Name: <abbr title='required'>*</abbr></label>
                    <input id='name' type='text' required/>

                <p data-test-my-form-item='description' class='form-item'>
                    <label for='description'>Description:</label>
                    <input id='description' type='text'/>

                <input data-test-my-submit-button class='submit-button' type='submit' value='Submit'/>


                #myInstructions {
    margin-bottom: 24px;

    color: steelblue;
    font-family: 'Arial';
    font-size: 24px;
    font-weight: bold;

#myContainer {
    display: flex;

    #myTable {
        th, td {
            border-bottom: 1px solid #ddd;
            padding: 8px 12px;

            font-family: 'Arial';

        th {
            background-color: #eee;

            &:hover {
                background-color: #ddd;
                cursor: pointer;

    #myForm {
        width: 40%;
        margin-left: 20px;

        .form-fieldset {
            background-color: #fafafa;
            font-family: 'Arial';

            .form-item {
                label, input {
                    display: block;
                    margin-bottom: 8px;

                label abbr {
                    border: none;
                    text-decoration: none;

                input {
                    width: 100%;
                    height: 20px;

            .submit-button {
                float: right;
                margin-top: 8px;
                width: 50%;

                font-size: 16px;

#myTest {
    margin-bottom: 20px;

    .help-link {
        font-family: 'Arial';
        font-size: 24px;
        margin-bottom: 16px;

#myPage {
    border: 1px solid black;
    padding: 8px;



    Get mock data

let data = [];
let nextAvailableId = 0;

// Use this to reset what we get from the backend
const loadData = () => {
    data = [
            id: 0,
            name: 'V',
            description: 'v is for victory'
            id: 1,
            name: 'e',
            description: undefined
            id: 2,
            name: 'o',
            description: undefined
            id: 3,
            name: 'h',
            description: 'h is for hello world, this is my first program'
            id: 4,
            name: 'U',
            description: 'u is for user experience'
            id: 5,
            name: 'y',
            description: 'y is for yo-yo'

    nextAvailableId = data.length;

// Get the data for the first time


    Update the table

let myTableBody = document.getElementById('myTableBody');

const displayTable = (data) => {
    myTableBody.innerHTML = '';

    data.forEach((datum, index) => {
        let row = myTableBody.insertRow();

        // Display name
        let cell_name = row.insertCell(0);
        let node_name = document.createTextNode(;


        // Display description (an optional field)
        let cell_description = row.insertCell(1);
        let node_description = document.createTextNode(datum.description || '');

        // Mark the row with a data-test tag
        row.setAttribute('data-test-my-row', '');

// Display the table for the first time


    Listen to form submission

let myForm = document.getElementById('myForm');

myForm.addEventListener('submit', (event) => {

    // Get form item values
    const name =;
    const description = myForm.description.value || undefined;

    // Pass the data to the backend, which returns a
    // success message
    const createDatum = new Promise((resolve, reject) => {
        setTimeout(() => {
                id: nextAvailableId,
            resolve('datum successfully created');

        }, 250);

    // Update the table
    createDatum.then(() => {

    // Reset the form = '';
    myForm.description.value = '';


    Write integration tests

QUnit.test('We loaded QUnit correctly.', function(assert) {

    const var1 = 1, var2 = 1;

    assert.ok(true, 'We like tautologies!');
    assert.equal(var1, var2, 'Here is another tautology!');

    const myInstructions = document.querySelectorAll('[data-test-my-instructions]');

    assert.equal(myInstructions.length, 1, 'We see 1 page instructions.');
    assert.equal(myInstructions[0].innerText, 'You can submit the form to add a table row.', 'The page instructions are correct.');

QUnit.test('We loaded the data correctly.', function(assert) {

    const myRows = document.querySelectorAll('[data-test-my-row]');

    // TODO #1:
    // Write a test to check that we have 6 rows.

    // END TODO #1


QUnit.test('We see the form correctly.', function(assert) {

    const myForm = document.querySelectorAll('[data-test-my-form]');
    const myFormItems = document.querySelectorAll('[data-test-my-form-item]');
    const mySubmitButton = document.querySelectorAll('[data-test-my-submit-button]');

    assert.equal(myForm.length, 1, 'We see 1 form.');
    assert.equal(myFormItems.length, 2, 'We see 2 form items.');
    assert.equal(mySubmitButton.length, 1, 'We see 1 submit button.');

    // TODO #2:
    // Write a test to check that the 1st form item is
    // labeled 'Name' and the 2nd 'Description'.

    // END TODO #2


QUnit.test('We can submit the form.', function(assert) {

    const myFormItems = document.querySelectorAll('[data-test-my-form-item]');
    const mySubmitButton = document.querySelector('[data-test-my-submit-button]');

    // Fill out the form
    let item_name        = myFormItems[0].getElementsByTagName('input')[0];
    let item_description = myFormItems[1].getElementsByTagName('input')[0];

    item_name.value = 'i';
    item_description.value = 'i is for integration test';

    assert.equal(item_name.value, 'i', 'We can enter the name.');
    assert.equal(item_description.value, 'i is for integration test', 'We can enter the description.');

    // Submit the form;

    // TODO #3:
    // Write a test to check that the table shows a
    // new row on the bottom.

    // END TODO #3

We would have called your functions earlier, but we were in a bind.