Skip to main content
100%

SVG foreignObject Example

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Dec 2, 2011

This example demonstrates that HTML content from an external file can be embedded and displayed directly within an SVG canvas, showing a structured text layout with a heading and paragraphs. The code uses D3's `d3.select` to target the body and append an SVG element, then creates a `foreignObject` that nests a complete XHTML body using `d3.html`. The `xhtml:body` element is styled with a specific font and populated with placeholder text, highlighting how SVG can contain rich HTML formatting through the foreignObject API.

AI-generated description
gpl-3.0 Licensed

Similar vizzes