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

              
                <a href="">Empty link tag</a>

<a href="">Link with empty href</a>

<a href="#">Link with # href</a>

<img src="https://via.placeholder.com/60x40/969696/cccccc">

<span style="">Span with style tag</span>

<span style="">Span with style tag <span>More stuff inside</span></span>
              
            
!

CSS

              
                
              
            
!

JS

              
                window.Litmus = window.Litmus || {};

Litmus.checkHTML = function() {
  let crimes = { 
    // Inline style attributes
    // This one has to go first because inline styles are used to highlight problem elements, which creates false positives
    '[style]': 'Inline style tags are bad because they introduce high specificity and make managing CSS difficult. If you’re setting visibility, a CSS utility class like .hidden is better. If you’re changing visual style, use a proper class for your component.',
    // Link with no href attribute
    'a:not([href])': 'If a link doesn’t take users to a new page, use a <button> element instead.',
    // Link with empty href attribute
    '[href=""]': 'If a link doesn’t take users to a new page, use a <button> element instead.',
    // Link with placeholder href value
    '[href="#"]': 'Link tags always need an href attribute. If this link doesn’t take users to a new page, use a <button> element instead.',
    // Images without alt tags
    'img:not([alt])': 'Image tags always need an alt attribute. It should include descriptive text unless it’s purely decorative, in which case it should be left empty.'
  }
  
  for (let key in crimes) {
    let selector = key;
    let explanation = crimes[key];
    
    // Create jQuery object from elements matching selector
    let elements = $(selector);
    
    if (elements.length) {
      
      // Visually highlight error elements
      $('head').append('<style>.html-crime { outline: 4px solid rgba(255,0,0,0.5) !important }</style>');
      $(elements).addClass('html-crime');
      
      // Add explanations for errors in console
      $(elements).each(function (value, i) {
        console.error(i, '\n\n' + explanation);
      });
    }
  }
}

Litmus.checkHTML();
              
            
!
999px

Console