Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

HTML

              
                <article>
  <h1>An alternative way of embedding YouTube videos without impacting web perf</h1>
  <a href="https://bojanvidanovic.com/posts/an-alternative-way-of-embedding-youtube-videos-without-impacting-web-perf/">Link to the tutorial</a>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Auctor urna nunc id cursus metus. Aliquam faucibus purus in massa tempor. Eu consequat ac felis donec et odio pellentesque diam volutpat.</p>
  <div class="youtube">
  <a href="https://www.youtube.com/watch?v=fGm6YzBrxiI" target="_blank">
    <figure>
      <img src="https://img.youtube.com/vi/fGm6YzBrxiI/default.jpg"
           srcset="https://img.youtube.com/vi/fGm6YzBrxiI/mqdefault.jpg 320w,                    https://img.youtube.com/vi/fGm6YzBrxiI/hqdefault.jpg 480w,                    https://img.youtube.com/vi/fGm6YzBrxiI/sddefault.jpg 640w,                    https://img.youtube.com/vi/fGm6YzBrxiI/hq720.jpg 1280w,                      https://img.youtube.com/vi/fGm6YzBrxiI/maxresdefault.jpg 1920w"
           alt="All Alone in the Night - Time-lapse footage of the Earth as seen from the ISS" />
      <figcaption>
        Mother Earth - Beautiful Nature Around The World 4K
      </figcaption>
    </figure>
  </a>
</div>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Auctor urna nunc id cursus metus. Aliquam faucibus purus in massa tempor. Eu consequat ac felis donec et odio pellentesque diam volutpat. Sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec pretium. Turpis cursus in hac habitasse platea dictumst quisque sagittis. Erat imperdiet sed euismod nisi porta lorem mollis. Orci ac auctor augue mauris augue neque gravida in fermentum. Quis viverra nibh cras pulvinar mattis nunc sed. Mattis nunc sed blandit libero. Ipsum nunc aliquet bibendum enim facilisis.</p>
</article>
              
            
!

CSS

              
                article {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.youtube {
  position: relative;

  a {
    text-decoration: none;
    
    &:before {
      content: '';
      width: 100%;
      height: 20%;
      position: absolute;
      top: 0;
      background-image: linear-gradient(#000, transparent);
    }

    &:after {
      content: "";
      background: url(https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/icons/youtube.svg)
        no-repeat;
      background-position: center;
      background-size: 100px 100px;
      position: absolute;
      top: 0;
      bottom: 0;
      right: 0;
      left: 0;
    }
  }
  
  img {
    width: 100%;
    height: auto;
  }

  figure {
    margin: 0;
  }

  figcaption {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console