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

              
                <h2>What’s the problem with CAPS in you text?</h2>
<p>When you use abbreviations like CSS, maybe HTML or PHP they usually draw much attention to themselves. This is because they are written in capital letters. Time to finetune your typography and replace those with small caps—short cap­i­tal let­ters de­signed to mingle with low­er­case text.</p>

<div id="caps-to-small-caps">
  <h2>And now with <span class="small-caps">small caps</span></h2>
<p>This JavaScript searches for all words within a list and adds a span to it to style them with small caps. So words like HTML or CSS won’t stand out that much anymore. Also CMS or PHP or maybe 12 KB, they are much more subtle and integrate better into your body text.</p>
<p>But please! Only use <em>real</em> small caps, not just scaled down capital letters you get from the dangerous font-variant: small-caps (<a href="https://practicaltypography.com/small-caps.html" target="_blank">find out why</a>). You can either load a web font that is all small caps, like Alegreya SC in this example or use a font that contains the OpenType font feature SMCP and activate it.</p>
<p>Many thanks to <a href="http://twitter.com/stevygee" target="_blank">Stefan</a> and <a href="https://codepen.io/PeterTheOne" target="_blank">Peter</a> for all that JavaScript. I don’t get anything of it, just here for the typography. They did all the magic.</p>
</div>
              
            
!

CSS

              
                 @import url('https://fonts.googleapis.com/css?family=Alegreya:400,400i|Alegreya+SC');

body {
  font-family: 'Alegreya';
  max-width: 32em;
  margin: 1.6rem auto;
  font-size: 120%;
  line-height: 1.6;
  margin: 
}

.small-caps {
  text-transform: lowercase;
  font-family: "Alegreya SC";
  letter-spacing: 0.03em;
}

p {
  margin: 0 0 1.6rem;
}

h2 {
  font-weight: 400;
  margin: 0 0 0.8rem;
  font-size: 1.8rem;
  padding-top: 0.8rem;
}

a:link,
a:visited {
  color: inherit;
  text-decoration-color: #006;
  text-decoation-skip: ink;
}

a:hover,
a:focus {
  color: #006;
  text-decoration: none;
}
              
            
!

JS

              
                /* Thanks to the code bros for the JS
http://twitter.com/stevygee and
http://twitter.com/petertheone
*/
var searchWords = ["CSS","HTML", "KB", "MB", "TB", "CMS", "PHP", "SMCP", "SC"];
var divContent = document.querySelectorAll("#caps-to-small-caps p");
for ( var j = 0; j < divContent.length; j++ ) {
  for ( var i = 0; i < searchWords.length; i++ ) {
    divContent[j].innerHTML = divContent[j].innerHTML.replace(new RegExp('(\s|\.|^)(' + searchWords[i] + ')(\s|\.|$)', 'g'), '$1<span class="small-caps">$2</span>$3');
  }
}
              
            
!
999px

Console