Problem Statement
How does SVG differ from Canvas in HTML5?
Explanation
SVG (Scalable Vector Graphics) uses XML-based markup to define vector shapes that scale without losing quality. Canvas is pixel-based, meaning graphics are drawn and rendered immediately as bitmap pixels. SVG is better for diagrams, icons, and scalable graphics, while Canvas is better for dynamic rendering like games or animations.
Code Solution
SolutionRead Only
<!-- Simple SVG Example --> <svg width="200" height="100"> <rect width="200" height="100" fill="lightblue" stroke="black"/> <circle cx="100" cy="50" r="30" fill="orange"/> <text x="60" y="55" font-size="16" fill="black">SVG</text> </svg>
