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.


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="starfield" class="darknight"></div>
<!-- Inspired by the marvelous work of Jhey at 

I found the best way to save the images you produce here is to change the view to full screen and print to PDF. The alternative (html2canvas.js) does a lousy job.



                * {box-sizing: border-box;}
body {margin:0;padding:0;overflow:hidden;}
#starfield {width:100vw;height:100vh;margin:0;padding:0;overflow:hidden;}
.pureblack {background: #000;}
.blacknight {background: linear-gradient(160deg, #010101, #010111, #010122);}
.darknight {background: linear-gradient(160deg, #030c20, #121b39, #2d4065);}
.lightnight {background: linear-gradient(160deg, #141d30, #232c4a, #3e5176);}
.twilight {background: linear-gradient(160deg, #25273a, #2e3755, #485b80);}
.star {position: absolute;background: #fbfbfc;border-radius: 100%;
  height: 1px;width: 1px;top: calc(var(--y) * 1vh);left: calc(var(--x) * 1vw);
  transform: scale(var(--scale));}
.pureblack .star {opacity: calc(var(--opacity) * 1.7);}
.blacknight .star {opacity: calc(var(--opacity) * 1.6);}
.darknight .star {opacity: calc(var(--opacity) * 1.5);}
.lightnight .star {opacity: calc(var(--opacity) * 1);}
.twilight .star {opacity: calc(var(--opacity) * 0.35);}


                //just change the star count to whatever you like
//also change the darkness level 0 through 4
//4 is best if the image will be tiled
let starcount = 1000;
let darkness = 2;

//only edit below if you wish to change functionality
let bgclasses = ["twilight","lightnight","darknight","blacknight","pureblack"];
document.addEventListener("DOMContentLoaded", makeStars, false);
function makeStars(){
  let html = "";
  for (let i=0;i<starcount;i++){
    let x = randRange(1,1000)/10;
    let y = randRange(1,1000)/10;
    let op = randRange(2,5)/10;
    let s = randRange(100,300)/100;
    html += `<div class="star" style="--x:${x}; --y:${y}; --opacity:${op}; --scale:${s};"></div>`;
  darkness = (darkness >= bgclasses.length) ? 4 : ((darkness < 0) ? 0 : darkness);
  document.getElementById("starfield").className = bgclasses[darkness];
  document.getElementById("starfield").innerHTML = html;

function randRange(min, max) {
  return Math.floor(Math.random()*(max-min+1))+min;