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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

  <h1 class="header">Screen Reader Friendly CSS Hover</h1>
  <p>This is a CSS hover that's accessible to screen readers. All the magic is done by the tabindex='0' attribute on the inner div (the one displayed on hover) and the CSS :focus-within property, which I've coupled with :hover. This allows the inner div to be tabbed onto and focused within. As a result, clicking inside the hovered div means it will not disappear when the cursor is moved away until something else is clicked on. CSS :focus-within does not work in IE, which really y'all shouldn't be using in 2019 anyways. Works in all other major browsers. Works in mobile, too.</p>
  <p><a href="">Focus test</a></p>
  <div class="container">
    <div class="hover" tabindex="0"><h1 class="header">Heading 1</h1><a href="">Focus-within Test</a>
      <p>The other thing with Lorem Ipsum is that you have to take out its family. We have so many things that we have to do better... and certainly ipsum is one of them. I will write some great placeholder text – and nobody writes better placeholder text than me, believe me – and I’ll write it very inexpensively. I will write some great, great text on your website’s Southern border, and I will make Google pay for that text. Mark my words. You're telling the enemy exactly what you're going to do. No wonder you've been fighting Lorem Ipsum your entire adult life.</p>

<p>Some people have an ability to write placeholder text... It's an art you're basically born with. You either have it or you don't. Trump Ipsum is calling for a total and complete shutdown of Muslim text entering your website. You have so many different things placeholder text has to be able to do, and I don't believe Lorem Ipsum has the stamina. Does everybody know that pig named Lorem Ipsum? She's a disgusting pig, right?</p>
              /* Some basic styling */
:root {
    --bg-color: #111;
    --txt-color: #eee;
    --link-color: #374c5d;
    --link2-color: #fff;
    --darktxt-color: #a0a0a0;
    --accent1-color: #232323;
    --accent2-color: #252D34;

*, html {font-size: 16px; line-height: 150%; box-sizing: border-box;}
body {background: var(--bg-color); color: var(--txt-color);font-family: arial, sans-serif;font-size: 1rem;}

a:link, a:visited, a:active {
  color: var(--link-color);
a:hover {
  color: var(--link2-color);

h1, h2, h3, h4, h5, h6 {
    display: block;
    font-size: inherit;
    font-weight: inherit;
    padding: 0;
    margin: 5px 0;
p {
    font-size: 1rem;
    margin: 5px 0;
    padding: 0;
    text-indent: 30px;

.header {
    background: var(--accent1-color);
    border-bottom: 10px solid var(--accent2-color);
    color: var(--darktxt-color);
    font-family: georgia, serif;
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 8px 2px;
    text-align: center;

main {
    border:2px solid var(--link-color);
    padding: 15px;

/* Hover Container and main background */
.container {
  width: 300px;
  height: 400px;
  margin: 10px auto;
  padding: 15px;
  background-color: var(--accent1-color);
  background: url('') center no-repeat;
  background-size: cover;
  border: 2px solid var(--accent2-color);
  z-index: 1;

/* The hover styles, opacity and z-index keep it hidden from view, transition is optional, but makes hovering smoother */
.hover {
  background: var(--bg-color);
  color: var(--darktxt-color);
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 10px;
  opacity: 0;
  z-index: 0;
  transition: all ease-in-out .2s;

/* focus-within is not supported in IE, but is REQUIRED in order for this to work otherwise just like tabindex="0" in the HTML section */
.container:hover .hover,
.container:focus-within .hover {
  opacity: 1;
  z-index: 1;

/* Eliminates the hover on small screens, resets width and height */
@media (max-width: 1000px) {
  .container, .hover {width: 100%; height: unset; z-index: 1; opacity: 1; visibility: visible;}
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.