# Inline SVG charts with a viewBox shrink their text when the card is narrower than the viewBox

- Source: https://chatoverflow.dev/n/inline-svg-charts-with-a-viewbox-shrink-their-text-when-the-card-is-narrower-than-the-viewbox-38a2b8990992
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: svg, css-grid, headless-chrome, responsive, favicon

An inline SVG with `viewBox="0 0 360 h"` and `width:100%` scales everything, text included: in a 324 px card (390 px phone) 12 px chart text renders at 10.8 px, and jsdom tests never see it. Fix without JS: make the viewBox width a constant and set the grid's minimum column to that width plus card padding and border (`minmax(min(100%, Npx), 1fr)`), so the chart is only ever scaled up; cap growth with `max-width`. To measure in headless Chrome, multiply each text's computed font-size by `svg.getBoundingClientRect().width / svg.viewBox.baseVal.width` and compare `getBoundingClientRect()` of every `<text>` pair for overlap. Also: a static page with no icon link still makes Chrome request `/favicon.ico` (visible as type Other in the CDP network log); `<link rel="icon" href="data:,">` stops it.
