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.




                * {
	box-sizing: border-box;
html, body {
	margin: 0;
	padding: 0;
	width: 100vw;
	height: 100vh;
body {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
.app {
	width: 75%;
	display: flex;
	flex-direction: column;
	font-family: sans-serif;
	font-weight: 100;

.app h1 {
	font-size: 14pt;
	font-weight: 500;
	margin: 5px 0;
.app h2 {
	font-size: 13pt;
	font-weight: 400;
	margin: 5px;
.app h3 {
	font-size: 12pt;
	font-weight: 300;
	margin: 15px 0 5px;

.app_desc {
	margin: 5px 0 15px;
.app_input {
	padding: 10px;
	font-size: 12pt;
	font-family: monospace;
	font-weight: 100;
.app_example {
	font-size: 10pt;
	text-decoration: none;
	align-self: flex-end;
	padding-top: 5px;
.app_html {
	font-family: monospace;
	padding: 5px;

.app_rendered-html {
	outline: solid 1px #aaa;
	padding: 5px;


                // quick tip: an import alias that loads npm modules!
const npm = p => import(`${p}?module`);

(async () => {
 const title =
  "Pulling and using NPM package Emmet as javascript module and using it in the browser";
 const desc =
  "This pen has no written HTML, as it is generated using ";
 const linkText = "Get random example";

 const appAbbr = `.app>(h1.app_title{${title}}+(blockquote.app_desc{${desc}}>a[href="" target="_blank"]{Emmet})+h2{Enter CSS abbreviation}+input.app_input[placeholder="Enter a CSS abbreviation" value=""]+a.app_example[href="#"]{${linkText}}+h3{HTML}+textarea.app_html+h3{Rendered HTML}+.app_rendered-html)`;
 const abbrs = [".test>table>thead>tr*3>th{$}","html:5", "table>tbody>tr*4>td*3{col $$}","#id.class{Div is default tag}", "h1{h1}+h2{h2}+h3{h3}+h4{h4}+h5{h5}+h6{h6}","#d$$*3","(.block>h2.block_title{Block $$}+img[src=])*3"];
 const emmet = await npm("emmet"); // Fetch the Emmet package from NPM as js module
 const html = emmet.default(appAbbr); // The abbrs[0] is this pen :-)
 // Add the app to the body
 const eleApp = (document.body.innerHTML = html);

 const appInput = document.querySelector(".app_input");
 const appHtml = document.querySelector(".app_html");
 const appExample = document.querySelector(".app_example");
 const appRenderedHtml = document.querySelector(".app_rendered-html");

 const action = () => {
  appHtml.value = emmet.default(appInput.value);
	 appRenderedHtml.innerHTML = appHtml.value;
const getRandom = (evt) => {
  if (evt) {
  const no = parseInt(Math.random() * abbrs.length);
  appInput.value = abbrs[no];

 // Add eventlistener to the input
 appInput.addEventListener("input", action);
 // Add eventlistener to the get random example
 appExample.addEventListener("click", (evt) => {getRandom(evt)});