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.


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.


                <div id="container">
  <h1>SpongeBob Meme Generator</h1>


                #container {
  box-sizing: border-box;
  left: 50%;
  max-width: 502px;
  min-width: 200px;
  padding: 5%;
  position: absolute;
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  top: 50%;
  width: 100%;
  padding: calc(10px);
  width: calc(100% - 20px);

#container > * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  text-align: center;
  width: 100%;

#container h1 {
  font-family: Arial, sans-serif;



                const memeGenerator = function(element) {
  // actual code of the challenge
  let formatText = function(message) {
    return message.split(" ")
                  .map(function(el) {
                    return el.split('')
                             .map(function(letter, idx) {
                               return idx % 2 === 0 ? letter.toLowerCase() : letter.toUpperCase();
                  .join(' ')
  // generate the elements in the meme generator
  const textarea = document.createElement("textarea");
  const canvas = document.createElement("canvas"); = "font-size: 20px; line-height: 25px; height: 50px;";
  textarea.placeholder = "Write your text here";

  // set up the canvas
  canvas.width = 502;     // actual image width
  canvas.height = 353;    // actual image height
  const ctx = canvas.getContext("2d");

  // load the image in the background
  const background = new Image();
  background.src = "";
  background.onload = function(){
    ctx.drawImage(background, 0, 0);   
  textarea.addEventListener("input", function() {
    const lines = formatText(this.value).split("\n");
    canvas.width = canvas.width;
    ctx.drawImage(background, 0, 0); 
    ctx.textAlign = "center";
    ctx.font = "50px Impact,sans-serif";
    ctx.fillStyle = "white";
    ctx.strokeStyle = "black";
    ctx.lineWidth = "2";
    for (let x = 1; x <= lines.length; x++) {
      ctx.fillText(lines[x-1], 251, 50 * x);
      ctx.strokeText(lines[x-1], 251, 50 * x);

const mg = document.querySelector("#container");