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.


                <body bgcolor="#F4F4FF" text="#000000" link="#0000FF" vlink="#7F0F9F" alink="#FF0000">

    <h1> Astronomy Picture of the Day </h1>
      Discover the cosmos!
      Each day a different image or photograph of our fascinating universe is
      featured, along with a brief explanation written by a professional astronomer.

      <span id="date"></span>
      <a id="hdurl" href="">
        <img id="url" src="" alt="" style="max-width:100%"></a>


    <b id="title"></b> 
    <b> Image Credit: </b>
    <a href="">NASA</a>,
    <a href="">ESA</a>;
      <b> Explanation: </b>
      <span id="explanation"></span>




                /** DOM Selectors*/

const date = document.getElementById("date");
const hdurl = document.getElementById("hdurl");
const imgUrl = document.getElementById("url");
const title = document.getElementById("title");
const explanation = document.getElementById("explanation");

/** API Request */
// Uncomment the path defined below, run at discretion given that it is a demo key.
// const path = "";

  .then(response => response.json())
  .then(data => {
    date.innerText =;
    hdurl.setAttribute = ("href", data.hdurl);
    imgUrl.setAttribute("src", data.url);
    imgUrl.setAttribute("alt", data.title);
    title.innerText = data.title;
    explanation.innerText = data.explanation;