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

              
                <p>
	some content goes here and <span data-spoiler>this is very spoilery. I can't <a href=#>believe you</a> just read this!</span> more content goes here
</p>

<hr>

<div data-spoiler>
	<p>What does a whole block of spoiler content look like?</p>
	I can't <a href=#>believe you</a> just read this!
<p>don't you feel a loss, knowing that the impact of the story is now dilluted due to your inability to not be spoiled?</p>
</div>


<hr>

<p>non-spoilery stuff here</p>
<div data-spoiler class=ani>
	<p>What does a whole block of spoiler content look like?</p>
	I can't <a href=>believe you</a> just read this!
<p>don't you feel a loss, knowing that the impact of the story is now dilluted due to your inability to not be spoiled?</p>
</div>
<p>more non-spoilery stuff here</p>
              
            
!

CSS

              
                [data-spoiler][inert] {
	filter: blur(8px)
}

[data-spoiler] {
	font-weight: bold;
}

.sp {
	position: relative;
	display: inline-block;
}

.spe {
	all: unset;
	text-align: center;
	font-size: .9em;
}

.spe span {
	border: 1px solid;
	padding: .25em .5em;
	background: #eee;
}

.spe:focus span {
	outline: 2px solid;
}

.spe[aria-expanded="false"] {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	margin: auto;
	z-index: 1;
}

.spe[aria-expanded="true"]:not(:focus):not(:hover) {
	font-size: .625em;
}

div > .spe[aria-expanded="true"] {
	margin-bottom: 1em;
	width: 100%;
}

span > .spe[aria-expanded="true"] {
	margin-right: .5em;
}

[data-spoiler].ani {
	padding-top: 0em;
	transition: padding .2s ease-in-out;
}

.spe[aria-expanded=true] + [data-spoiler].ani {
	padding-top: .625em;
}

.sp:has(.ani) .spe[aria-expanded=true] {
	position: absolute;
	margin: 0;
	background: #aaa;
}

.sp:has(.ani) .spe[aria-expanded="true"]:not(:focus):not(:hover) {
	font-size: .75em;
}

div.sp:has(.spe[aria-expanded="true"])::after {
	content: "/spoiler" / "";
	text-align: center;
	display: block;
	position: relative;
	z-index:1;
	text-shadow: -3px 3px 4px #fff,
				  3px 3px 4px #fff,
				  3px -3px 0 #fff,
				  -3px -3px 0 #fff;
	
}
div.sp:has(.spe[aria-expanded="true"])::before {
	content: '';
	background: #aaa;
	height: 2px;
	width: 100%;
	position: absolute;
	bottom: 8px;
}
              
            
!

JS

              
                const sp = document.querySelectorAll('[data-spoiler]');


// i should have just used a custom element and set it to display block or display inline/inline-block based on its parent.  but i already wrote this, so whaver...
for ( let i = 0; i < sp.length; i++ ) {
	const self = sp[i];
	let w;
	if ( sp[i].tagName == 'SPAN') {
		w = document.createElement('span');
	}
	else {
		w = document.createElement('div');
	}
	w.role = 'group';
	w.ariaLabel = 'spoiler';
	w.classList = 'sp';
	self.inert = true;
	
	self.parentNode.insertBefore(w, self);
	w.appendChild(self);
	
	const b = '<button aria-expanded="false" class="spe"><span>Reveal Spoiler</span></button>';
	sp[i].insertAdjacentHTML('beforebegin', b);
}

const sb = document.querySelectorAll('.spe');
for ( let i = 0; i < sb.length; i++ ) {
	sb[i].addEventListener('click', function () {

		if ( this.ariaExpanded == 'false') {
			this.ariaExpanded = true;
			sp[i].inert = false;
		}
		else {
			this.ariaExpanded = false;
			sp[i].inert = true;
		}
	})
}

              
            
!
999px

Console