Sure! Here's an HTML file containing multiple nested SVG elements. These SVGs contain various weird dimension units (like em, vw, %, vh, cm, mm), some have viewBox attributes, some don't, and the nesting is deeply done arbitrarily. This can be used for extensive testing of SVG rendering and dimension handling.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Nested Weird SVG Test</title>
<style>
body {
background: #222;
color: white;
font-family: monospace;
padding: 2em;
}
svg {
border: 1px dashed lime;
margin: 1em;
display: block;
}
</style>
</head>
<body>
<h1>Nested Weird SVG Example</h1>
<!-- Outer SVG with % dimensions, no viewBox -->
<svg width="80%" height="40vh" style="background:#111;">
<rect x="0" y="0" width="100%" height="100%" fill="#444" />
<!-- Nested SVG with cm units and missing viewBox -->
<svg x="1cm" y="1cm" width="4cm" height="3cm" style="background:#660044; border:1px solid red;">
<circle cx="2cm" cy="1.5cm" r="1cm" fill="orange" />
<!-- Nested SVG with weird units and valid viewBox -->
<svg x="0.5cm" y="0.5cm" width="150%" height="150%" viewBox="0 0 50 50" style="background:#004466; border:1px solid cyan;">
<rect x="10" y="10" width="30" height="30" fill="lime" />
<!-- Another nested SVG missing viewBox -->
<svg x="5mm" y="5mm" width="80mm" height="60mm" style="background:#220066;">
<ellipse cx="40mm" cy="30mm" rx="30mm" ry="20mm" fill="yellow" />
<!-- Deeply nested with vw/vh units and incomplete viewBox -->
<svg x="10vw" y="5vh" width="20vw" height="10vh" viewBox="0 0 100 50" style="background:#663300; border:2px dotted white;">
<polygon points="10,40 50,10 90,40" fill="pink" />
<!-- Nested with em units missing viewBox -->
<svg x="1em" y="1em" width="10em" height="7em" style="background:#003300;">
<line x1="0" y1="0" x2="10em" y2="7em" stroke="white" stroke-width="0.1em" />
<!-- Nested with % but missing viewbox -->
<svg x="10%" y="10%" width="50%" height="50%" fill="none" stroke="yellow" stroke-width="2">
<path d="M0 0 L100 0 L50 50 Z" />
</svg>
</svg>
</svg>
</svg>
</svg>
</svg>
<!-- Independent weird SVG with mm units and viewBox -->
<svg x="5%" y="80%" width="150mm" height="70mm" viewBox="0 0 150 70" style="background:#220011; border:1px solid white;">
<text x="10" y="35" font-size="20" fill="pink">Test Text</text>
<circle cx="130" cy="35" r="25" fill="none" stroke="pink" stroke-width="3" />
</svg>
<!-- Independent weird SVG, % units, missing viewBox -->
<svg x="60%" y="5%" width="15%" height="20%" style="background:#111144; border:1px dashed orange;">
<rect x="5%" y="5%" width="90%" height="90%" fill="orange" opacity="0.4" />
<circle cx="50%" cy="50%" r="40%" fill="none" stroke="white" stroke-width="2" />
</svg>
</svg>
</body>
</html>
Explanation:
- The outermost SVG is sized in
% and vh units.
- Inside, the nested SVGs have
cm, mm, em, vw, and vh units for x, y, width, and height.
- Some nested SVGs have valid
viewBox attributes, others omit them entirely.
- There's deep nesting going multiple levels in to test how rendering engines or parsers handle it.
- Background colors and borders are added for clarity on layout and nesting boundaries.
Feel free to save the file and open it in your browser to see how it renders. It should provide a comprehensive test case for your needs!