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.


      <h1>Jared's Food</h1>
      <p>Click on an image to enlarge.</p>
      <ul id="image_list">
          <a href="" title="All Purpose Seasoning"
            ><img src="" alt="All Purpose Seasoning"
          <a href="" title="BBQ Seasoning"
            ><img src="" alt="BBQ Seasoning"
          <a href="" title="Whole Cardomon"
            ><img src="" alt="Whole Cardomon"
          <a href="" title="Umami Salt"
            ><img src="" alt="Umami Salt"
          <a href="" title="Red Pepper Flakes"
            ><img src="" alt="Red Pepper Flakes"
      <h2 id="caption"></h2>
      <p id="holder"><img src="" alt="" title="" id="main_image" /></p>


  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;

  display: flex;
  justify-content: center;
li {

   list-style: none;
li img{
  width: 50%;


                onload = () => {
  // getElementById function
  const $ = (id) => {
    return document.getElementById(id);

  // Variables
  const listNode = $("image_list"); // ul element
  const captionNode = $("caption"); //h2 element
  const imageNode = $("main_image"); //main img element
  const holder = $("holder"); // get 'p' element
  let imageLinks = listNode.getElementsByTagName("a"); //grabs the links in the ul list
  [...imageLinks].forEach((imgLink) => {
    let height = 300;
    let width = 325;
    //Create the larger images
    let image = new Image(width, height);
    // Get href attribute of each img from image list
    image.src = imgLink.getAttribute("href");
    image.title = imgLink.getAttribute("title");
    // When you click on a thumbnail, larger img will appear
    //Click again and image will switch to new one
    imgLink.onclick = (e) => {
      captionNode.textContent = image.title;
    }; //end event handler
  }); //end 'foreach'