-
Hajipur, Bihar, 844101
SVG (Scalable Vector Graphics) is an XML-based format used to define vector-based graphics for the web. Unlike raster images (e.g., PNG, JPEG), SVG graphics do not lose quality when scaled or zoomed.
SVG is used to create lines, shapes, text, and images that are scalable, stylable, and scriptable using CSS and JavaScript.
Scales without losing quality (perfect for logos and icons)
Easily styled with CSS
Can be animated with JavaScript or CSS
Smaller file size for simple graphics
<svg width="200" height="100">
<rect width="200" height="100" style="fill:lightblue;" />
</svg>
Element | Description |
---|---|
<svg> |
Container for SVG content |
<rect> |
Draws a rectangle |
<circle> |
Draws a circle |
<ellipse> |
Draws an ellipse |
<line> |
Draws a line |
<polyline> |
Series of connected straight lines |
<polygon> |
Closed shape with multiple sides |
<path> |
Defines complex shapes and curves |
<text> |
Adds text to SVG |
<svg width="300" height="100">
<rect width="300" height="100" style="fill:tomato;" />
</svg>
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" fill="green" />
</svg>
<svg height="100" width="200">
<line x1="0" y1="0" x2="200" y2="100" stroke="black" stroke-width="2" />
</svg>
<svg width="300" height="100">
<text x="20" y="50" font-family="Arial" font-size="24" fill="blue">
Hello SVG
</text>
</svg>
<svg width="200" height="200">
<path d="M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80"
stroke="black" fill="transparent"/>
</svg>
Q1. Draw a red rectangle of 200x100 size using SVG.
Q2. Create a green circle with a radius of 40 pixels.
Q3. Add a line from top-left to bottom-right of a 200x100 area.
Q4. Display the text "Welcome to SVG" using the <text>
element.
Q5. Create a blue ellipse with rx=50
and ry=25
.
Q6. Use <polygon>
to create a triangle.
Q7. Style an SVG shape using CSS instead of style
attribute.
Q8. Animate a circle’s radius using CSS or JavaScript.
Q9. Use <path>
to draw a complex wave shape.
Q10. Create a group of SVG shapes using <g>
tag and apply a transformation.
Q1: What does SVG stand for?
Q2: Which element is used to draw a circle in SVG?
Q3: Which SVG element is used for complex shapes?
Q4: What does the cx and cy attributes in <circle> represent?
Q5: What happens when you scale an SVG image?
Q6: Which tag is the container for all SVG graphics?
Q7: How do you fill a shape with color in SVG?
Q8: Which element is used to add text inside SVG?
Q9: Which SVG element creates connected line segments?
Q10: How can SVG be styled?