Back to the library

Setting — hanging punctuation

Variant: Hanging punctuation

A pull quote whose opening mark is moved out of the text block, so the letters, not the punctuation, form the left edge. A dashed proof rule is drawn down the edge first, 392ms on an ease-out, and shows lines two and three already sitting on it while line one is pushed in by a quotation mark. Then the line slides one glyph left in 336ms on the in-out curve. It is already on screen and only moving, so it must not read as an entrance. The mark is pinned to the outside of the first line with right: 100%, which hangs it by exactly its own width in whatever serif the system supplies. Only the uncorrected state uses an estimate, 0.45em, roughly the mark's width in Georgia. The mark takes the clay accent only as it lands, since colouring it earlier would flag it as the problem before the rule does, and the rule lifts once the fix is in, because the fix should leave no trace. Reach for it on pull quotes, testimonials and blockquotes in editorial layouts. hanging-punctuation does this for real in Safari; elsewhere an em-based negative text-indent gets close, with the same estimate this piece uses for its before state.

texttypographylayoutloop

The source

A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Setting — hanging punctuation</title>
    <style>
      :root {
        /* Neutrals — fixed, never remixed. */
        --ivory: #faf9f5;
        --paper: #ffffff;
        --oat: #e3dacc;
        --slate: #141413;

        /* Knobs — the remix API. A knob exists iff declared here and used below. */
        --hue: 38.8;
        --lift: 0;
        --chroma: 1;
        --round: 1;
        --speed: 1;

        /* Accents — derived from the knobs with the family's offsets baked in,
           so one hue roll moves them together. Defaults reproduce the original hex
           (#d97757 / #b85c3e / #788c5d / #b04a3f). */
        --clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
        --clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
        --olive: oklch(
          calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3)
        );
        --rust: oklch(
          calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3)
        );

        /* Clock — 5.6s, shared across the setting family. The proof mark goes
           down at 16%, the correction lands by 32%, the mark is lifted by
           56%, and the card resets inside a blank window at 93%. */
        --cycle: 5.6s;
        --t: calc(var(--cycle) / var(--speed));

        --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
        --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

        --_quiet: color-mix(in srgb, var(--slate) 55%, transparent);

        /* The opening mark's advance in Georgia, approximately. It only sizes the wrong
           state — the corrected state hangs the mark by its own exact width. */
        --_hang: 0.45em;
      }

      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }

      body {
        min-height: 100vh;
        display: grid;
        place-items: center;
        padding: clamp(12px, 3vw, 28px);
        background: var(--ivory);
        color: var(--slate);
        font-family:
          system-ui,
          -apple-system,
          'Segoe UI',
          Roboto,
          sans-serif;
      }

      .sheet {
        width: min(360px, 92vw);
        padding: clamp(14px, 3.4vw, 22px) clamp(16px, 3.8vw, 26px);
        border: 1px solid var(--oat);
        border-radius: calc(14px * var(--round));
        background: var(--paper);
      }

      /* The whole set resets inside one blank window, so the loop never shows
         the correction being undone — a fix that visibly reverses reads as a
         second animation with the opposite meaning. */
      .stage {
        animation: seam var(--t) infinite;
      }

      .eyebrow {
        font-size: clamp(11px, 2.4vw, 12.5px);
        font-weight: 600;
        letter-spacing: 0.09em;
        text-transform: uppercase;
        color: var(--_quiet);
      }

      .foot {
        margin-top: clamp(12px, 2.6vw, 16px);
        padding-top: clamp(9px, 2vw, 12px);
        border-top: 1px solid var(--oat);
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 6px 12px;
      }

      .foot code {
        font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
        font-size: clamp(11px, 2.6vw, 12.5px);
        color: var(--_quiet);
        white-space: nowrap;
      }

      /* The state chip rolls on a two-row track rather than crossfading, so no
         frame has both words legible. */
      .chip {
        height: calc(1.6em + 2px);
        overflow: hidden;
        padding: 0 0.7em;
        border: 1px solid var(--oat);
        border-radius: 999px;
        font-size: clamp(11px, 2.5vw, 12px);
        font-weight: 600;
        line-height: 1.6em;
        color: var(--_quiet);
      }

      .track {
        display: block;
        animation: roll var(--t) infinite;
      }

      .track > span {
        display: block;
        white-space: nowrap;
      }

      .track .set {
        color: var(--slate);
      }

      .track .set::before {
        content: '';
        display: inline-block;
        width: 0.45em;
        height: 0.45em;
        margin-right: 0.4em;
        border-radius: 50%;
        background: var(--olive);
        vertical-align: 0.08em;
      }

      @keyframes roll {
        0%,
        32% {
          transform: translateY(0);
          animation-timing-function: var(--ease-out);
        }
        36%,
        92.9% {
          transform: translateY(-50%);
        }
        93%,
        100% {
          transform: translateY(0);
        }
      }

      @keyframes seam {
        0%,
        88% {
          opacity: 1;
          animation-timing-function: ease;
        }
        92%,
        94% {
          opacity: 0;
          animation-timing-function: ease;
        }
        98%,
        100% {
          opacity: 1;
        }
      }

      .quote {
        position: relative;
        margin-top: clamp(10px, 2.2vw, 14px);
        font-family: ui-serif, Georgia, 'Times New Roman', serif;
        font-size: clamp(17px, 4.6vw, 22px);
        line-height: 1.34;
        color: var(--slate);
      }

      .ln {
        display: block;
        white-space: nowrap;
      }

      /* The mark is pinned to the outside of the first line's own box, so in
         the set state it hangs by exactly its advance width whatever the
         system serif turns out to be. Only the typed state is an estimate. */
      .l1 {
        position: relative;
        animation: hang var(--t) infinite;
      }

      .mark {
        position: absolute;
        right: 100%;
        top: 0;
        color: var(--slate);
        animation: mark var(--t) infinite;
      }

      /* The mark takes the accent only once it hangs: coloured in the typed
         state it would announce itself as the problem before the proof rule
         has said so. */
      @keyframes mark {
        0%,
        26% {
          color: var(--slate);
          animation-timing-function: ease;
        }
        32%,
        92.9% {
          color: var(--clay);
        }
        93%,
        100% {
          color: var(--slate);
        }
      }

      .cite {
        margin-top: clamp(6px, 1.4vw, 9px);
        font-size: clamp(11.5px, 2.7vw, 13px);
        color: var(--_quiet);
      }

      /* The proof mark is the text edge itself, ruled top to bottom as a
         dashed hairline: the claim being made is that lines two and three are
         already on it and line one is not. */
      .guide {
        position: absolute;
        left: 0;
        top: 0.2em;
        bottom: 0.2em;
        width: 1px;
        background: repeating-linear-gradient(to bottom, var(--clay) 0 3px, transparent 3px 6px);
        animation: guide var(--t) infinite;
      }

      @keyframes guide {
        0%,
        16% {
          clip-path: inset(0 0 100% 0);
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        23%,
        46% {
          clip-path: inset(0 0 0 0);
          opacity: 1;
          animation-timing-function: ease;
        }
        56%,
        100% {
          clip-path: inset(0 0 0 0);
          opacity: 0;
        }
      }

      /* 336ms on the in-out curve: the line is already on screen and only
         moving, and it moves the width of one glyph — so it must not feel
         like an entrance. */
      @keyframes hang {
        0%,
        26% {
          transform: translateX(var(--_hang));
          animation-timing-function: var(--ease-in-out);
        }
        32%,
        92.9% {
          transform: translateX(0);
        }
        93%,
        100% {
          transform: translateX(var(--_hang));
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* Every travel distance in the piece goes to zero time — positions cut
           between their two states inside a frame — while the proof marks,
           which say what is about to change and that it changed, keep fading
           on a slower clock. */
        .stage,
        .track,
        .l1,
        .guide {
          animation-duration: calc(var(--t) * 1.7);
        }

        .track {
          animation-name: roll-rm;
        }

        @keyframes roll-rm {
          0%,
          32.9% {
            transform: translateY(0);
          }
          33%,
          92.9% {
            transform: translateY(-50%);
          }
          93%,
          100% {
            transform: translateY(0);
          }
        }

        .l1 {
          animation-name: hang-rm;
        }

        .guide {
          clip-path: none;
          animation-name: guide-rm;
        }

        @keyframes hang-rm {
          0%,
          28.9% {
            transform: translateX(var(--_hang));
          }
          29%,
          92.9% {
            transform: translateX(0);
          }
          93%,
          100% {
            transform: translateX(var(--_hang));
          }
        }

        @keyframes guide-rm {
          0%,
          16% {
            opacity: 0;
            animation-timing-function: ease;
          }
          23%,
          46% {
            opacity: 1;
            animation-timing-function: ease;
          }
          56%,
          100% {
            opacity: 0;
          }
        }
      }
    </style>
  </head>
  <body>
    <div class="sheet">
      <div class="stage">
        <p class="eyebrow">Pull quote</p>
        <blockquote class="quote">
          <span class="guide" aria-hidden="true"></span>
          <span class="ln l1"><span class="mark">“</span>The frame should</span>
          <span class="ln">disappear, so the</span>
          <span class="ln">work is all you see.”</span>
        </blockquote>
        <p class="cite">— notes from the framing bench</p>
        <div class="foot">
          <code>hanging-punctuation: first</code>
          <span class="chip" aria-hidden="true"
            ><span class="track"><span>as typed</span><span class="set">as set</span></span></span
          >
        </div>
      </div>
    </div>
  </body>
</html>

The variant family

Same idea, one axis moved. Compare them side by side before you commit.