cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

    <h1>Lab: Pixel Art Maker</h1>

    <h2>Choose Grid Size</h2>

    <form id="sizePicker">
        Grid Height:
        <input type="number" id="inputHeight" name="height" min="1" value="1">
        Grid Width:
        <input type="number" id="inputWidth" name="width" min="1" value="1">
        <input type="submit">

    <h2>Pick A Color</h2>
    <input type="color" id="colorPicker">

    <h2>Design Canvas</h2>
    <table id="pixelCanvas">
      <!-- append grid here -->

              body {
    text-align: center;

h1 {
    font-family: Monoton;
    font-size: 70px;
    margin: 0.2em;

h2 {
    margin: 1em 0 0.25em;

h2:first-of-type {
    margin-top: 0.5em;

td {
    border: 1px solid black;

table {
    border-collapse: collapse;
    margin: 0 auto;

tr {
    height: 20px;

td {
    width: 20px;

input[type=number] {
    width: 6em;

/** Custom CSS **/

table {
    table-layout: fixed;
    /* Under the "fixed" layout method, the entire table can be rendered once the first table row has been downloaded and analyzed. */

                  /***** IMPORTANT TODO: Consolidate local and copeden work *****/

                                 /* TODO: Push all work to GitHub */


        var $submit = $("input[type=submit]");
        var inputHeight = $("#inputHeight").attr("value", 10); // inital height, width = 10
        var inputWidth = $("#inputWidth").attr("value", 10);  


    /** DONE: add input value functionality **/

        $submit.on("click", function(evt){
            makeGrid(inputHeight.val(), inputWidth.val());

        /* FUNCTION: Make a grid! */
        function makeGrid(height, width) {

            for (var row = 0; row < height; row++) {
                // create row
                var table = $("#pixelCanvas"); // #pixelCanvas
                var tr = document.createElement("tr");
                for (var col = 0; col < width; col++) {
                    var td = document.createElement("td");
                    // $(td).addClass("fill");
                    $(tr).append(td); // 10 times



    /***** IMPORTANT TODO: Consolidate local and copeden work *****/

                                 /* TODO: Push all work to GitHub */

    /* FUNCTION: Pick a color! */

    /** TODO: Build colorPicker functionality
        1) Select Color
        2) Assign Selected Color to currentColor
        3) Test: console.log(current color)

        Fixed: Able to set color for table, not for td. Why?
          => ".on( events [, selector ] [, data ], handler )"


    /** TODO: Create function for colorPicker  
        TODO: Fix for "submit" appending additonal grids
        TODO: V2: Feature to reset grid
        TODO: V2: Mobile-compliance for colorPicker
        TODO: V2: Feature for removing color


        $('#pixelCanvas').on('click', 'td', function() {
            var colorPicker = $("input[type=color]");
            var currentColor = colorPicker.val();


    /***** IMPORTANT TODO: Consolidate local and copeden work *****/

                                 /* TODO: Push all work to GitHub */

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................