cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <button type="button">
  Toggle letter-spacing and kerning
</button>

<main>

  <p 
     id="letter-spacing"
     class="example-letter-spacing">
    martinez
  </p>

  <hr />
  
  <svg 
    id="kerning"
    class="example-kerning"
    aria-labelledby="title description"
    role="img"
    xmlns="http://www.w3.org/2000/svg"
    viewBox="0 0 238 48">
    <title id="title">Aviation</title>
    <desc id="description">A demonstration of kerning where the letters A and V are brought closer together to improve legibility. The type is set in Cormorant, a serif typeface designed for larger display on digital screens.</desc>
    <path id="letter-1" d="M51.016,45.724c-2.736,0-5.833-.288-8.569-.288-3.1,0-4.968.288-7.776.288-.432,0-.432-.864,0-.864,4.752,0,5.616-1.224,3.528-5.472L30.135,22.61H16.886l-5.9,13.681c-2.52,5.76-.072,8.568,5.977,8.568.432,0,.432.864,0,.864-2.88,0-4.824-.288-8.5-.288-3.528,0-5.112.288-8.137.288-.432,0-.432-.864,0-.864,3.816,0,5.833-1.8,9-9.289L24.662.216c.072-.288.937-.288,1.08,0L42.952,35.859c3.385,7.057,5.257,9,8.065,9C51.449,44.86,51.449,45.724,51.016,45.724ZM29.343,20.954,23.15,8.065,17.606,20.954Z"/>
    <g id="letters-2-8">
      <path id="letter-2" d="M81.4,18.794c-2.52,0-4.176,1.512-5.9,5.616L66.566,45.652a1.221,1.221,0,0,1-1.656,0L54.54,23.906c-2.016-4.32-3.1-5.112-5.04-5.112-.216,0-.216-.864,0-.864,1.512,0,3.24.144,5.688.144,3.456,0,5.833-.144,7.993-.144.216,0,.216.864,0,.864-3.024,0-5.113.5-3.96,2.808l8.641,17.786,5.977-15.193c1.44-3.6-.144-5.4-4.824-5.4-.216,0-.216-.864,0-.864,2.3,0,3.96.144,7.272.144,2.16,0,3.168-.144,5.112-.144C81.615,17.929,81.615,18.794,81.4,18.794Z"/>
      <path id="letter-3" d="M84.449,44.86c3.456,0,4.32-1.008,4.32-4.968V26.642c0-4.969-1.3-5.833-5.4-3.889-.36.144-.72-.72-.36-.864l9.865-4.608c.432-.216.936.36.936.648,0,1.008-.144,3.888-.144,8.569V39.891c0,3.96.792,4.968,4.32,4.968.288,0,.288.864,0,.864-1.8,0-4.176-.144-6.769-.144s-4.968.144-6.769.144C84.161,45.724,84.161,44.86,84.449,44.86Zm2.664-39.1c0-2.088,1.368-3.312,3.6-3.312A3.052,3.052,0,0,1,94.1,5.76c0,2.232-1.224,3.528-3.384,3.528A3.275,3.275,0,0,1,87.113,5.76Z"/>
      <path class="letter-4" d="M128.809,42.628l-7.417,3.528c-1.368.648-3.168-.864-3.6-4.249l-4.033,2.16c-2.736,1.44-4.9,2.16-6.84,2.16-3.1,0-4.752-1.8-4.752-4.392,0-2.88,2.16-3.96,7.272-5.761l8.209-2.808v-5.9c0-6.408-1.656-8.568-4.32-8.568-3.1,0-4.608,2.664-4.969,5.833-.144,1.8-1.008,3.168-3.168,3.168-1.8,0-2.736-.936-2.736-2.448,0-3.672,8.353-8.064,13.393-8.064,3.816,0,6.769,2.448,6.769,7.92V37.947c0,4.537,1.656,5.688,5.833,3.889C128.882,41.692,129.242,42.411,128.809,42.628Zm-11.161-1.8V34.275l-6.265,2.376c-2.376.792-3.24,1.872-3.24,3.456a2.951,2.951,0,0,0,3.1,3.241,7.009,7.009,0,0,0,3.168-.864Z"/>
      <path class="letter-5" d="M150.12,42.34c-3.528,3.024-6.265,4.249-9.577,4.249-3.528,0-7.129-1.368-7.129-6.121V23.834c0-3.312-.648-3.96-3.744-3.96-.288,0-.288-1.08,0-1.08,4.249-.072,6.913-2.16,7.633-5.617.072-.36,1.08-.36,1.08,0v5.544c3.24-.072,6.264-.36,9.792-.72.288,0,.5.72.5,1.656,0,.864-.36,1.944-.72,1.872a43.507,43.507,0,0,0-9.577-1.152V38.019c0,3.96,2.088,5.688,5.544,5.688a9.447,9.447,0,0,0,5.688-2.016C149.976,41.4,150.48,42.052,150.12,42.34Z"/>
      <path class="letter-6" d="M153.891,44.86c3.456,0,4.32-1.008,4.32-4.968V26.642c0-4.969-1.3-5.833-5.4-3.889-.36.144-.72-.72-.36-.864l9.865-4.608c.432-.216.936.36.936.648,0,1.008-.144,3.888-.144,8.569V39.891c0,3.96.792,4.968,4.32,4.968.288,0,.288.864,0,.864-1.8,0-4.176-.144-6.769-.144s-4.968.144-6.769.144C153.6,45.724,153.6,44.86,153.891,44.86Zm2.664-39.1c0-2.088,1.368-3.312,3.6-3.312A3.052,3.052,0,0,1,163.54,5.76c0,2.232-1.224,3.528-3.384,3.528A3.275,3.275,0,0,1,156.556,5.76Z"/>
      <path class="letter-7" d="M169.759,31.467c0-9.937,8.425-14.473,15.554-14.473,8.929,0,14.185,7.345,14.185,14.905,0,9-7.2,14.761-15.409,14.761C175.232,46.66,169.759,39.6,169.759,31.467Zm23.834,2.665c0-10.153-5.04-15.7-10.873-15.7-4.608,0-7.2,3.528-7.2,10.585,0,9.649,4.752,16.273,10.729,16.273C190.857,45.292,193.593,41.692,193.593,34.131Z"/>
      <path class="letter-8" d="M236.577,45.724c-1.8,0-4.176-.144-6.769-.144s-4.968.144-6.769.144c-.288,0-.288-.864,0-.864,3.457,0,4.32-1.008,4.32-4.968V28.658c0-5.544-2.016-8.065-6.408-8.065a11.581,11.581,0,0,0-8.064,3.889V39.891c0,3.96.792,4.968,4.32,4.968.288,0,.288.864,0,.864-1.8,0-4.177-.144-6.769-.144s-4.969.144-6.769.144c-.288,0-.288-.864,0-.864,3.456,0,4.32-1.008,4.32-4.968V25.922c0-4.752-1.513-5.473-6.265-3.528-.36.216-.72-.648-.36-.792l9.146-4.32c.863-.432,2.3,1.656,2.376,5.833,3.456-4.032,7.057-6.049,11.017-6.049,5.257,0,8.353,3.168,8.353,8.785V39.891c0,3.96.792,4.968,4.32,4.968C236.865,44.86,236.865,45.724,236.577,45.724Z"/>
    </g>
  </svg>

</main>

            
          
!
            
              // Transitions
$default-transition: 500ms ease-in-out;

// Colors
$bird-flower: #d5ca17;
$cod-gray: #151515;
$harp: #e6f2e9;
$gray: #8a8a8a;
$vermilion: #ff4300;

// Fonts
$montserrat: 'Montserrat', sans-serif;

// Mixins
@mixin horizontally-center() {
  position: absolute;
    bottom: 1.5em;
    left: 50%;
  transform: translateX(-50%);
  width: auto;  
}

html {
  background-color: $harp;
}

body {
  background-color: $harp;

  font-family: $montserrat;
  line-height: 1;
}

button {
  @include horizontally-center();

  padding: 0.5em 1.5em;
  width: 80%;

  border: none;
  border-bottom: 2px solid darken($bird-flower, 20%);
  border-radius: 0.5em;

  background-color: $bird-flower;
  
  color: $cod-gray;

  cursor: pointer; // A little extra affordance for the CodePen embed
  
  // States
  &:hover,
  &:focus {
    background-color: darken($bird-flower, 5%);
  }
  
  &:active {
    bottom: calc(1.5em - 1px);

    border-top: 3px solid darken($bird-flower, 40%);
    border-bottom: 1px solid darken($bird-flower, 30%);

    background-color: darken($bird-flower, 20%);
    
    transition: none;
  }
  
  // Media Queries
  @media screen and (min-width: 25em) {
    width: initial;
  }
}

main {
  margin-top: 10vh; // macOS Safari creates a shearing effect when applying letter-spacing to an element that has been horizontally and vertically centered.

  text-align: center; // macOS Safari also appears to ignore text-align as a letter-spacing origin point. It will extend to the right as opposed to center outwards.
}

.example-letter-spacing {
  margin-top: 0;
  margin-bottom: 0.65em;

  color: $cod-gray;
  font-size: calc(1em + 3vw);

  transition: letter-spacing $default-transition;
  will-change: letter-spacing;
  
  // States
  &.is-active {
    letter-spacing: 0.25em;    
    transition: letter-spacing $default-transition;

    // Feature Queries
    @media screen and (prefers-reduced-motion: reduce) {
      transition: none;
    }
  }

  // Feature Queries
  @media screen and (prefers-reduced-motion: reduce) {
    transition: none;
  }
}

hr {
  margin-bottom: 2em;
  width: 50%;

  border-top: 4px double $gray; 
  border-right: none;
  border-bottom: none;
  border-left: none;
}

.example-kerning {
  margin-bottom: 15vh;
  width: 70vw;
  
  fill: $vermilion;
  
  #letter-1,
  #letters-2-8 {
    transform: translate(0, 0);
    transition: transform $default-transition;
    will-change: transform;
    
    // Feature Queries
    @media screen and (prefers-reduced-motion: reduce) {
      transition: none;
    }
  }

  // States
  &.is-active {
    #letter-1 {
      transform: translate(0.2em, 0);
      transition: transform $default-transition;
      
      // Feature Queries
      @media screen and (prefers-reduced-motion: reduce) {
        transition: none;
      }
    }
    
    #letters-2-8 {
      transform: translate(-0.2em, 0);
      transition: transform $default-transition;
      
      // Feature Queries
      @media screen and (prefers-reduced-motion: reduce) {
        transition: none;
      }
    }
  }
}
            
          
!
            
              const button = document.querySelector('button');

function toggleLetterSpacingKerning() {
  var letterSpacing = document.getElementById('letter-spacing');
  var kerning = document.getElementById('kerning');
  var kerningTarget = document.getElementById('letter-3');

  letterSpacing.classList.toggle('is-active');
  kerning.classList.toggle('is-active');
}

button.addEventListener('click', toggleLetterSpacingKerning);
            
          
!
999px
Loading ..................

Console