Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                
<ol class='question-list'>
	<li class='question' data-id='1'>
		
		<question-card>
			<a class='question-link' href='/'>
				<h4 class='prompt'>
					What is a good example question?
				</h4>
			</a>

			<nav class='actions'>
				<a class='link' href=''>Answer</a>

				<a class='link' href=''>
					šŸ’¬ <span>0</span>
				</a>

				<a class='link' href=''>
					šŸ‘„ <span>0</span>
				</a>

				<button rel='follow-toggle'>
					Follow
				</button>
			</nav>
		</question-card>
		
	</li>
	
	<!-- pulling in this other HTML from a pen / to mimic a dynamic list -->
	[[[https://codepen.io/sheriffderek/pen/f85472d96356b7e90f9d81db018919af]]]

	[[[https://codepen.io/sheriffderek/pen/f85472d96356b7e90f9d81db018919af]]]

	[[[https://codepen.io/sheriffderek/pen/f85472d96356b7e90f9d81db018919af]]]
</ol>

              
            
!

CSS

              
                /* RESET */
a {
	text-decoration: none;
	color: inherit;
}

/* COMPONENTS */
question-card {
	display: block; /* custom-elements are 'inline' by default */
	padding: 20px;
}

question-card .question-link {
	display: block;
}

question-card .prompt {
	font-family: Sans-serif;
	font-size: 18px;
	line-height: 1.3;
}

question-card .actions {
	font-family: Sans-serif;
	font-size: 13px;
	margin-top: 10px;
}

question-card .actions > * {
	font-size: 10px;
	text-transform: uppercase;
	margin-right: 10px; /* in a real project... you'll want to make these links and buttons bigger (padding) - so that they have larger 'touch' areas. In a real job / you might work on this one component for days... and often... (user-interface is a lot more than just 'getting it done') */
}

/* CONTEXT (Well, this is really ALSO a component)*/
.question-list {
	/* padding-top: 60px; */
}

.question-list .question {
	border-bottom: 1px solid lightgray;
}

.question-list .question:first-of-type {
	border-top: 1px solid lightgray;
}

/* CONTEXT (page) */
body { /* for example / imaging body.landing-page main  */
	max-width: 400px;
}


/* first break-point (when there is more space available) */
@media (min-width: 400px) {
	body { /* for example / imaging body.landing-page main  */
		padding: 20px;
	}
	body .question-list { /* small screens don't have room for this */
		box-shadow: 2px 3px 5px rgba(0,0,0,.2);
	}
}

              
            
!

JS

              
                
/* just for fun */
document.addEventListener('click', function(event) {
	// this is called "event delegation"

	if ( event.target.matches('a') ) {
		event.preventDefault();
		alert(`(link) Go to the right page... `);
	}
	

	if ( event.target.matches('[rel="follow-toggle"]') ) {
		var id = event.target.closest('.question').dataset.id; /* maybe? */
		alert(`Toggle follow for question ${id}`);
	}

});

              
            
!
999px

Console