Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
SVG (Scalable Vector Graphics) is an XML-based format for creating graphics that scale perfectly at any size. Unlike raster images (PNG, JPG), SVGs use mathematical vectors to define shapes, making them crisp on any screen.
Use <rect> element with x, y, width, height
Use <circle> with cx, cy, r attributes
Use <ellipse> with rx and ry radii
Use <line> with x1, y1, x2, y2 coordinates
<svg width="200" height="150">
<rect x="20" y="20" width="100" height="80"
fill="#f97316" stroke="#ea580c" stroke-width="2"/>
</svg>Click play to see all SVG shapes in action
<div class="shapes-demo">
<h3>Basic SVG Shapes</h3>
<svg viewBox="0 0 500 150" class="shapes-svg">
<!-- Rectangle -->
<rect x="20" y="20" width="100" height="80" fill="#f97316" rx="5"/>
<!-- Circle -->
<circle cx="200" cy="60" r="40" fill="#06b6d4"/>
<!-- Ellipse -->
<ellipse cx="320" cy="60" rx="60" ry="40" fill="#ec4899"/>
<!-- Line -->
<line x1="20" y1="130" x2="150" y2="130" stroke="#8b5cf6" stroke-width="2"/>
<!-- Polygon (Triangle) -->
<polygon points="300,20 340,100 260,100" fill="#10b981"/>
</svg>
</div>Loading preview...
Fill color of the shape
fill="#8b5cf6"Border/outline color
stroke="#6d28d9"Border thickness
stroke-width="3"Transparency (0-1)
opacity="0.5"Coordinate system
viewBox="0 0 200 200"Scale behavior
preserveAspectRatio="xMidYMid"Different colors, strokes, and opacity
<div class="svg-demo-container">
<h3>Simple SVG Circle</h3>
<svg viewBox="0 0 200 200" class="svg-canvas">
<circle cx="100" cy="100" r="80" fill="#8b5cf6" stroke="#6d28d9" stroke-width="4"/>
</svg>
<p class="demo-info">Vector-based circle that scales infinitely</p>
</div>Loading preview...
The <path> element uses a series of commands to draw custom shapes. Here are the main commands:
Move to a position without drawing
Draw a line to a point
Draw a curved line
Draw a smooth curved line
Connect back to start point
Lines, curves, and closed shapes
<div class="path-demo">
<h3>SVG Paths & Drawing</h3>
<svg viewBox="0 0 300 200" class="path-svg">
<!-- Simple path drawing -->
<path d="M 50 150 L 150 50 L 250 150" stroke="#3b82f6" stroke-width="3" fill="none"/>
<!-- Curved path -->
<path d="M 50 50 Q 100 20 150 50 T 250 50" stroke="#ec4899" stroke-width="3" fill="none"/>
<!-- Closed path -->
<path d="M 50 100 L 100 80 L 150 100 L 100 120 Z" fill="#10b981" opacity="0.7"/>
</svg>
<p class="path-info">Paths use commands: M (move), L (line), Q (quadratic curve), Z (close)</p>
</div>Loading preview...
You can add text to SVG using the <text> element. Text can be styled with CSS or SVG attributes and even follow curved paths!
<svg width="300" height="100">
<text x="10" y="50" font-size="32" fill="#3b82f6">
SVG Text
</text>
</svg>Regular text and text following a curved path
<div class="text-demo">
<h3>Text in SVG</h3>
<svg viewBox="0 0 400 150" class="text-svg">
<!-- Simple text -->
<text x="20" y="40" class="text-heading">SVG Text</text>
<!-- Styled text -->
<text x="20" y="80" class="text-content">Beautiful typography in SVG</text>
<!-- Path text -->
<path id="textPath" d="M 20 120 Q 100 100 380 120" stroke="none"/>
<text class="text-curved">
<textPath href="#textPath" startOffset="50%" text-anchor="middle">
Text follows a path
</textPath>
</text>
</svg>
</div>Loading preview...
Since SVG elements are part of the DOM, you can add event listeners and dynamically change their properties with JavaScript.
element.setAttribute('fill', '#new-color')element.addEventListener('click', callback)@keyframes animationelement.animate() APIHover and click SVG elements to interact
<div class="interactive-svg">
<h3>Interactive SVG Shapes</h3>
<svg viewBox="0 0 300 300" class="interactive-canvas">
<!-- Hover circle -->
<circle id="hoverCircle" cx="100" cy="100" r="40" fill="#8b5cf6" class="interactive-shape"/>
<!-- Click square -->
<rect id="clickSquare" x="180" y="60" width="80" height="80" fill="#06b6d4" class="interactive-shape"/>
<!-- Hover text -->
<text id="hoverText" x="100" y="250" text-anchor="middle" class="svg-text">Hover over shapes</text>
</svg>
</div>Loading preview...
Crisp icons at any resolution
Interactive data visualizations
Smooth animated graphics
Scalable brand assets
Interactive geographic displays
Buttons, badges, decorations