Certainly! Below is an HTML example that includes multiple nested SVG elements. These SVGs use weird dimension units (like pt, pc, em, %, vw, vh, cm, mm), and some have missing or random viewBox properties. Each SVG is independent and uses quirky shapes and styles to emphasize their "weirdness."
html Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Nested Weird SVGs</title>
<style>
body {
background: #111;
color: #eee;
font-family: monospace, monospace;
text-align: center;
padding: 20px;
}
svg {
border: 1px solid #444;
margin: 10px;
background: #222;
display: inline-block;
}
</style>
</head>
<body>
<h1>Nested Weird SVG Code Example</h1>
<!-- Outer SVG with odd dimensions and no viewBox -->
<svg width="25pc" height="15pc" xmlns="http://www.w3.org/2000/svg">
<!-- Nested SVG #1 with em units and viewBox -->
<svg x="2em" y="1em" width="10em" height="7em" viewBox="0 0 100 70" xmlns="http://www.w3.org/2000/svg" style="background:#222; border:2px dashed #66ccff;">
<circle cx="50" cy="35" r="30" fill="lime" stroke="purple" stroke-width="5" />
<text x="50" y="40" font-size="12" text-anchor="middle" fill="#000" font-family="Courier New">Nested 1</text>
</svg>
<!-- Nested SVG #2 with % units (missing viewBox) -->
<svg x="50%" y="50%" width="40%" height="40%" xmlns="http://www.w3.org/2000/svg" style="background:#440; border:1px solid #ee5533;">
<rect width="100" height="100" fill="url(#grad1)" />
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
</linearGradient>
</defs>
<polygon points="10,90 50,10 90,90" fill="cyan" stroke="magenta" stroke-width="3" />
</svg>
<!-- Nested SVG #3 with vw and vh units and odd viewBox -->
<svg x="10vw" y="5vh" width="20vw" height="15vh" viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg" style="background:#003344; border:3px dotted #ffeebb;">
<ellipse cx="100" cy="50" rx="90" ry="40" fill="orange" stroke="black" stroke-width="2" />
<line x1="10" y1="90" x2="190" y2="10" stroke="lime" stroke-width="4" />
<text x="100" y="55" font-size="18" text-anchor="middle" fill="black" font-family="Arial Black">Nested 3</text>
</svg>
<!-- Nested SVG #4 with cm and mm units and weird missing viewBox -->
<svg x="1cm" y="10mm" width="6cm" height="4cm" xmlns="http://www.w3.org/2000/svg" style="background:#550055; border:5px double #ff55ff;">
<path d="M 10 80 Q 95 10 180 80" stroke="white" fill="transparent" stroke-width="6" />
<circle cx="100" cy="50" r="30" fill="transparent" stroke="yellow" stroke-width="10" />
</svg>
<!-- Nested SVG #5 nested inside Nested SVG #1 with weird units and missing viewbox -->
<svg x="60%" y="60%" width="4em" height="4em" xmlns="http://www.w3.org/2000/svg" style="background:#222222; border:1px solid #ffffff;">
<rect width="100" height="100" fill="none" stroke="lime" stroke-width="4" />
<circle cx="50" cy="50" r="40" fill="none" stroke="red" stroke-width="5" />
<text x="50" y="56" font-size="14" text-anchor="middle" fill="lime" font-family="Comic Sans MS">Tiny</text>
</svg>
</svg>
</body>
</html>
Explanation:
The outermost SVG uses pc units (picas) for width and height and has no viewBox defined.
Inside it are multiple independent SVGs nested via the <svg> tag, each with varying dimension units:
Nested #1: uses em units with a viewBox.
Nested #2: uses % units with no viewBox , inside uses gradients and polygons.
Nested #3: uses viewport width/height units (vw, vh) and an unusual viewBox.
Nested #4: uses physical units like cm and mm, no viewBox .
Nested #5: nested inside Nested #1 (as a child SVG element), using mixed units and missing viewBox.
Styles are applied inline and via CSS for readability, and quirky color and stroke combos make the shapes stand out.
The presence and absence of viewBox on some SVGs will yield different scaling or clipping behaviors.
Feel free to open this HTML file in any modern browser to see the weird nested SVGs in action!