모노스페이스

Monospace

모든 글자가 정확히 같은 폭을 차지하는 서체. i와 m이 같은 자리를 차지합니다.

다른 이름: 고정폭 서체Fixed-width
···
html
<div class="stage">
  <div class="row">
    <div class="txtwrap mono">
      <div class="grid" id="gridA"></div>
      <span class="txt">design_01();</span>
    </div>
    <div class="cap">ui-monospace</div>
  </div>
  <div class="row">
    <div class="txtwrap prop">
      <div class="grid" id="gridB"></div>
      <span class="txt">design_01();</span>
    </div>
    <div class="cap">system-ui (비례폭)</div>
  </div>
</div>
css
.stage{display:grid;gap:14px;justify-items:center}
.row{display:grid;gap:6px;justify-items:center}
.txtwrap{position:relative;display:inline-block}
.txtwrap .txt{display:block;font-size:clamp(15px,5.5vmin,24px);letter-spacing:0;white-space:pre;color:var(--fg);position:relative;z-index:1}
.mono .txt{font-family:ui-monospace,Menlo,'SFMono-Regular',monospace}
.prop .txt{font-family:system-ui,-apple-system,sans-serif}
.grid{position:absolute;inset:-2px 0;z-index:0;animation:pulse 2.4s ease-in-out infinite}
.cap{font:11px ui-monospace,Menlo,monospace;color:var(--muted)}
@keyframes pulse{0%,100%{opacity:.3}50%{opacity:.8}}
js
const gridA = document.getElementById('gridA');
const gridB = document.getElementById('gridB');
const monoTxt = document.querySelector('.mono .txt');
function setup(){
  const cs = getComputedStyle(monoTxt);
  const c = document.createElement('canvas').getContext('2d');
  c.font = cs.fontWeight + ' ' + cs.fontSize + ' ' + cs.fontFamily;
  const w = Math.max(c.measureText('0').width, 4);
  const bg = 'repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px ' + w + 'px)';
  gridA.style.backgroundImage = bg;
  gridB.style.backgroundImage = bg;
}
setup();
addEventListener('resize', setup);

일반 서체(비례 폭, proportional)는 i가 m보다 좁게 그려지고, 그만큼 자연스러운 리듬으로 읽힙니다. 모노스페이스는 반대로 모든 글자 폭을 강제로 맞춰서, 타자기 출신답게 세로줄이 정확히 맞아떨어지는 표·코드 정렬에 유리합니다.

코드 에디터, 터미널, 표 형식 숫자(가격·시간)에 널리 쓰입니다. 숫자가 자릿수를 맞춰 정렬돼야 하는 곳(영수증, 대시보드 지표)에도 `font-variant-numeric: tabular-nums`로 숫자만 고정폭으로 만드는 절충안이 있습니다.

웹에서는 `ui-monospace`(OS 기본 모노스페이스, macOS의 SF Mono 등)를 CDN 없이 바로 쓸 수 있고, 폴백으로 `Menlo`, `Consolas`, `monospace`를 둡니다.

언제 쓰나

코드, 터미널 출력, 자릿수를 맞춰야 하는 표 형식 숫자에. 일반 본문에는 쓰지 마세요 — 읽는 속도가 느려집니다.