Skip to content

Show SVG images that have no width of their own - #219

Merged
eric-schneider merged 1 commit into
mainfrom
t2-svg-sizing
Nov 19, 2026
Merged

eric-schneider merged 1 commit into
mainfrom
t2-svg-sizing

Conversation

@eric-schneider

Copy link
Copy Markdown
Contributor

An SVG image whose file sets no width of its own, such as one with only a viewBox or with width="100%", rendered at 0×0 and disappeared from the page. That held for a block image, for an SVG embedded with an <object> tag (opts=interactive) and for inline SVG.

This adopts upstream's fcb2110: a block image's content box stretches to the full width of the block, and the image inside it is aligned with text-align. An SVG without a width then fills the column, or the table cell it's in, in Chromium, WebKit and Firefox. Images that set a width, SVGs that declare their own size, and images with alignment roles or floats stay where they were.

Upstream also sizes an <object> SVG that has no width attribute with width: fit-content (f96f0fb), a rule docs-ui dropped in #61. It stays out: with the stretched content box it changes nothing in Chromium, while in WebKit it shrinks such an SVG to the default object size and in Firefox to nothing.

site.css grows by 197 bytes, 25 bytes gzipped.

An SVG image whose file sets no width, such as one with only a viewBox
or with width="100%", rendered at 0x0 and disappeared from the page.
That holds for a block image, for an SVG embedded with an <object> tag
for interactivity, and for inline SVG.

Stretch a block image's content box to the full width of the block and
align the image inside it with text-align, as upstream's fcb2110 does.
An SVG without a width then fills the column in Chromium, WebKit and
Firefox, and the text-left and text-right roles still align narrower
images.

Upstream also sizes an <object> SVG that has no width attribute with
width: fit-content (f96f0fb), a rule docs-ui dropped in #61. It stays
out: with the stretched content box it changes nothing in Chromium,
and it shrinks such an SVG to the default object size in WebKit and to
nothing in Firefox.
@eric-schneider eric-schneider self-assigned this Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

UI bundle preview build successful! ✅
Deploying bundle preview.
Deploy successful! View preview

@plpesvc-ds

plpesvc-ds commented Nov 19, 2026 •

Copy link
Copy Markdown

Build successful! ✅
Deploying draft.
Deploy successful! View draft

@eric-schneider
eric-schneider merged commit 70607f2 into main Nov 19, 2026
2 checks passed
@eric-schneider
eric-schneider deleted the t2-svg-sizing branch November 19, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants