Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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.


	h1.s5 CSS vertical rhythm
	p.s0 Testing an adaptive ruleset for vertical rhythm, responsive to the <code>font-size</code> of the parent container. Set the parent's <code>font-size</code> to whatever you want the vertical rhythm's base to be.

	- for i in (0..2)
		div class='#{i == 0 ? 'g' : 'g v'}'
			.s0 #{i == 0 ? 'Unaligned' : 'Aligned'}
				- for i in (0..6)
					p class='s#{7-i}' #{7-i}: Jalapeno pepper and garlic add a fragrant zing.
					p.s0.serif For an infused oil, simply combine 7 parts oil with a pinch of sea salt and freshly ground black pepper to taste. Seal the jar and shake for 30 seconds, until the salt is fully dissolved in the oil. Uncap the jar and add 1 part ground herb or spice of your choice. Reseal the jar and shake until emulsified.
				p.s0 0: Jalapeno pepper and garlic add a fragrant zing.
				p.s-1 -1: Jalapeno pepper and garlic add a fragrant zing.
				p.s-2 -2: Jalapeno pepper and garlic add a fragrant zing.
p.s7 Copy the CSS here:



	margin: 0

	font: 900 30.6px/1.7 arial, "Helvetica Neue", helvetica, sans-serif
	color: #444

	text-align: center
	margin: 1em auto 4em
	max-width: 560px

	display: flex
	& > * 
		flex-grow: 1
		flex-shrink: 1
		flex-basis: 0
		overflow: hidden

	font-size: 40px
	padding: 0 1em
		white-space: nowrap
			white-space: normal

.g.v + .g.v
	background: repeating-linear-gradient(#ced, #ced 1em, #ccf 1em, #ccf 2em)

	text-decoration: underline

	font-weight: normal
	font-family: georgia, palatino, 'Palatino Linotype', times, 'Times New Roman', serif

	font: inherit



                // Note: this just automates the CSS writing. You don't need it in your final site, just copy the generated CSS at the bottom of the page :)

// "eem": effective em. The font size of the parent container.
const nOver = 7;
const nUnder = 2;
const scale = 1.25;
const ratio = 1.7; // Ratio of line height to font size.
const elements = {
	1: ['p'],
	2: ['h3', 'h4'],
	3: ['h2'],
	5: ['h1'],
const sizes = Array.from({length: nOver + nUnder + 1}, (_, i) => nOver - i);
const fontSizes = => Math.pow(scale, s) / ratio);
const format = n => +n.toFixed(10);
const variables = [`:root {
${, i) => `\t--s${sizes[i]}: ${format(fontSize)}em;`).join('\n')}
// Note from the future: all of these were being overwritten anyway so
//  I removed them from the final stylesheet.
// const unalignedRules = [`${Object.values(elements).flat().sort().concat( => `.s${s}`)).map(selector => `.m ${selector}`).join(', ')} {
// \tmargin: 0.8em 0 0.3em;
// }`];
const alignedRules =, i) => {
  // Line height is 1eem. Base font size is 1eem / 1.7.
  const fontSize = fontSizes[i];
  let lineHeight;
  const reciprocal = lineHeight = 1 / fontSize;
  while (lineHeight < 1.3) lineHeight += reciprocal;
  // If the size gap between the line height and the text is greater than .5eem, skip the bottom margin.
  // Otherwise, add a margin of 1 eem.
  const marginBottom = (lineHeight - 1) * fontSize > 0.5 ? 0 : `${format(reciprocal)}em`;
  // However many ems the font size is (rounded down, min 1), that's how many eems we add on top.
  const marginTop = `${format(reciprocal * Math.max(1, Math.floor(fontSize)))}em`;
  const selectors = (elements[s] || []).concat(`.s${s}`);
  return `${selectors.join(', ')} {
\tfont-size: var(--s${s});
${ => `.v ${selector}`).join(', ')} {
\tline-height: ${format(lineHeight)}em;
${ => `.m ${selector}`).join(', ')} {
\tmargin: ${marginTop} 0 ${marginBottom};

document.querySelector('pre').textContent = document.querySelector('.restyle').textContent = variables.concat(alignedRules).join('\n');