Adjusting Kerning in CSS

Kerning, letter-spacing (aka tracking) and justify blocks are three different typography properties.

The newest link I found about kerning is from TypeKit, with directions on how to enable the embedded kerning data with their webfonts. http://blog.typekit.com/2014/02/05/kerning-on-the-web/#comment-19916

Manual kerning - adjusting the space between each single letter in a word - will always be a matter of taste and preference. And can be achieved thru kern.js or kerning.js

What makes the TypeKit solution stand out to me, is it enables kerning for all body text automatically by utilizing the meta data in OpenType fonts. I just found it, and am pretty excited to use it in my next project!

For easy reference, the new css properties discussed in the link are:

text-rendering: optimizeLegibility;
font-feature-settings: "kern";
font-kerning: normal;

With prefixes for font-feature-settings including:

  -webkit-font-feature-settings: "kern";
  -moz-font-feature-settings: "kern";
  -moz-font-feature-settings: "kern=1";

As user Typeoneerror answered, letter-spacing does not influence kerning. See the kerning concept at Wikipedia.

Kerning is not controlled by letter-spacing, and there are no font-kerning for CSS1 or CSS2. The new specification, CSS3, has not been approved as a standard (W3C Recommendation), but there are a property proposed for font-kerning, see 2012 draft,

https://www.w3.org/TR/css-fonts-3/#font-kerning-prop

Only specific fonts, like OpenFonts, have this property.

CSS not "controls kerning", but if using non-zero letter-spacing the "human kerning perception" can be lost. Example: enhance kerning with letter-spacing:-0.1em and lost with letter-spacing:0.5em.

With CSS1 letter-spacing property you can lost or enhance kerning perception, and into a "letter-spaced text" you can simulate kerning:

<div style="font-size:20pt;background-color:#bcd">

  VAST   <small>(normal)</small> 
  <br/>

  <span style="letter-spacing:-0.1em">VAST</span>  
  <small>(enhance perception)</small>
  <br/>

  <span style="letter-spacing:0.5em">VAST</span> 
  <small>(lost perception)</small>
  <br/>

  <!-- SIMULATE KERNING AT SPACED TEXT -->
  <div style="letter-spacing:6pt">
     SIMULATE: <span style="letter-spacing:4pt">VA</span>ST TEXT
  </div>

</div>

See the above example here.


EDIT 2014: I not changed the original text above today, I am opening the answer for your changes (Wiki mode), for proofreading and updates. At the moment this is the most voted answer (21 vs 10) and HTML5 will be a recommendation... Please, help to improve this text (and/or the Wikipedia's linked text!).


Some control on kerning can be achieved in CSS using the letter-spacing attribute.

However, if all you need is to get "both left and right edges aligned", you might want to try using text-align: justify.

EDIT: CSS3 defines a font-kerning property that can be used to enable or disable kerning for specific elements.


Typographic alignment both left and right is called justification. Kerning is more about the adjustment of spaces between letters, and doesn't have much to do with alignment (because justifying text is more adjustment of spaces between words than characters). Anyway, you want to set the text-align property to justify:

<p style="text-align: justify">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vestibulum tincidunt ante mollis ornare. Nulla id
    nulla justo. Mauris quis sapien ac orci consequat accumsan. Quisque iaculis ipsum ac nulla venenatis sagittis. Aliquam
    hendrerit mi a turpis malesuada nec dictum est vehicula. Curabitur quis dolor eu metus malesuada dictum adipiscing et
    risus. Aliquam erat volutpat. Aenean pharetra aliquam magna, fringilla tempus erat iaculis eu. Suspendisse potenti.
    Sed fringilla lobortis viverra.
</p>

Tags:

Css