Certainly! Below is an HTML code snippet containing multiple nested SVG elements. The SVGs use a variety of dimension units (px, %, em, vw, vh), some missing viewBox attributes randomly, and irregular/nested structures for thorough testing.
<!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 {
font-family: Arial, sans-serif;
background: #fafafa;
}
svg {
border: 1px solid #ccc;
margin: 10px;
}
</style>
</head>
<body>
<h1>Nested Weird SVGs for Testing</h1>
<!-- Outer SVG with vw and vh units, no viewBox -->
<svg width="30vw" height="20vh" style="background:#e3f2fd;">
<rect width="100%" height="100%" fill="#bbdefb" />
<!-- Nested SVG with % units and viewBox -->
<svg x="5%" y="10%" width="40%" height="60%" viewBox="0 0 200 100" style="background:#c8e6c9;">
<circle cx="50%" cy="50%" r="40" fill="#388e3c" />
<!-- Further Nested SVG with em units, no viewBox -->
<svg x="1em" y="1em" width="8em" height="4em" style="background:#ffe0b2;">
<ellipse cx="4em" cy="2em" rx="3em" ry="1em" fill="#f57c00" />
</svg>
</svg>
<!-- Sibling nested SVG with px units, missing viewBox -->
<svg x="60%" y="20px" width="120px" height="80px" style="background: #ffccbc;">
<polygon points="0,0 60,0 30,80" fill="#d84315" />
<!-- Nested SVG inside polygon SVG with mixed units and viewBox -->
<svg x="10px" y="10px" width="50px" height="50px" viewBox="0 0 50 50" style="background:#fff3e0;">
<line x1="0" y1="0" x2="50" y2="50" stroke="#bf360c" stroke-width="2" />
<line x1="50" y1="0" x2="0" y2="50" stroke="#bf360c" stroke-width="2" />
</svg>
</svg>
</svg>
<!-- Independent SVG with em units and missing viewBox -->
<svg width="15em" height="15em" style="background:#f3e5f5;">
<rect x="1em" y="1em" width="13em" height="13em" fill="#7b1fa2" />
<!-- Nested SVG inside, % units, with viewBox -->
<svg x="10%" y="10%" width="80%" height="80%" viewBox="0 0 100 100" style="background:#ede7f6;">
<path d="M10 80 Q 52.5 10, 95 80 T 180 80" fill="none" stroke="#4a148c" stroke-width="3" />
<!-- Nested SVG with vw units and no viewBox -->
<svg x="5vw" y="5vw" width="5vw" height="5vw" style="background:#d1c4e9;">
<circle cx="50%" cy="50%" r="40%" fill="#311b92" />
</svg>
</svg>
</svg>
<!-- Standalone SVG with px units, with viewBox -->
<svg width="200px" height="100px" viewBox="0 0 200 100" style="background:#e1f5fe;">
<text x="10" y="50" font-family="Verdana" font-size="35" fill="navy">Test</text>
<!-- Nested SVG missing width and height but with viewBox -->
<svg x="120" y="20" viewBox="0 0 50 50" style="background:#b3e5fc;">
<rect x="5" y="5" width="40" height="40" fill="#0288d1" />
</svg>
</svg>
</body>
</html>
Explanation
- Multiple SVGs nested inside one another.
- Dimensions use
px, %, em, vw, vh.
- Some SVGs omit
viewBox intentionally.
- Nested elements inside SVGs including
<rect>, <circle>, <ellipse>, <polygon>, <line>, <path>, <text>.
- Different placements using
x, y with various units.
- Background colors to visually separate the SVG boundaries.
You can save this code as an .html file and open it in any modern browser to test rendering with weird/nested SVG usage. Let me know if you want the code more complex or with specific features!