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.

              <h1>WebKit &lt;=536.11 font load bug</h1>
<p>WebKit versions prior to 536.11 have a bug where the normal CSS font stack is ignored while loading web fonts. Instead of falling back on the next font it will fall back to the generic font family (or the default generic font family) of the first instance the web font is mentioned in CSS. It switches to this font immediately while loading the web font, causing two changes in font (whereas other browsers only change font when the web font has loaded.)</p>

<h2 id="header" style="font-family: monospace; display: inline-block;white-space:nowrap;font-variant:small-caps;">This should display in monospace and then Sniglet</h2>

<p>The following log shows the three states of web font loading: before loading, during loading and after loading.</p>
<pre id="log"></pre>
<p>Browsers without the fallback bug will have identical widths for the first two states and a different width for the third state (given a clean cache). Browsers with the bug will show three unique widths for each state.</p>
<p>The bug has been fixed and only happens in WebKit versions below 536.11. See also WebKit bug <a href="https://bugs.webkit.org/show_bug.cgi?id=76684">#76684</a>.</p>
              var h2 = document.getElementById('header'),
    log = document.getElementById('log');

log.textContent += 'Width of header before load: ' + h2.offsetWidth + 'px.\n';

h2.style.fontFamily = 'sniglet, monospace';

log.textContent += 'Width of header during load: ' + h2.offsetWidth + 'px.\n';

// Use a setTimeout of 3 seconds. We assume the font has loaded after 3 seconds. It would
// be more accurate to detect font loading, but this would unnecessarily complicate the
// example.
window.setTimeout(function () {
  log.textContent += 'Width of header after load:  ' + h2.offsetWidth + 'px.\n';
}, 3000);

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................