All effectsVisual styles

Text Outline

描边文字

A stroke follows each glyph, so the letterforms stay readable with a transparent center.

Look at the letter outlines and see the background through them

Where to use it

Create a large decorative title over a quiet background. Give the outline enough weight to survive at small screen sizes, and use it on a few large letters so the reader can recognize them at a glance.

Practical example

An indie magazine opens its typography issue with a large outlined “TYPE” across a pale cover. The open letter interiors let the paper texture show through, while the issue number and article titles sit below in filled type.

AI prompt

Give [target heading] a Text Outline. Use a legible solid text color first, then apply text stroke and transparent fill in supporting browsers. Keep real text in the page and restore the fill for forced-color or low-contrast contexts.

Example code

Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.

View HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Text Outline</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .visual-specimen {
      width: min(100%, 290px);
      height: 124px;
      display: grid;
      place-items: center;
      position: relative;
      isolation: isolate;
    }
    .outline-word { font-size: clamp(24px, 12vw, 39px); line-height: 1.1; letter-spacing: .06em; color: #e9caa4; }
    @supports (-webkit-text-stroke: 1px #e9caa4) {
      .outline-word { -webkit-text-stroke: 1.4px #e9caa4; -webkit-text-fill-color: transparent; }
    }
    @media (forced-colors: active) {
      .outline-word { -webkit-text-stroke: 0; -webkit-text-fill-color: currentColor; }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="visual-specimen" aria-hidden="true"><b class="outline-word">Outline</b></div>
  </main>
</body>
</html>

Original example by UI Skills