Create SVG from Scratch: Beginner's Complete First Project Tutorial Without Design Tools
Creating SVG from scratch—writing code directly in a text editor—feels intimidating initially but provides unmatched understanding of how vector graphics actually work. Unlike visual tools hiding complexity, hand-coding reveals structure, teaching transferable knowledge applicable to any SVG project.
After teaching SVG fundamentals to thousands of beginners, analyzing successful learning patterns, and identifying concepts preventing comprehension breakthroughs, we've developed step-by-step tutorials enabling anyone to create professional SVG graphics from absolute zero. Our svg creator complements this learning by showing visual results of code concepts.
This complete beginner's guide takes you from "I don't understand SVG" to "I can create graphics with code" through hands-on projects. Follow along, type code yourself (don't copy-paste—typing builds muscle memory), and watch your confidence grow with each completed exercise.
Getting Started: Zero to First SVG
What You Need
Required:
- Text editor (Notepad, TextEdit, VS Code, Sublime Text—any will work)
- Web browser (Chrome, Firefox, Safari, Edge)
Optional but helpful:
- Browser DevTools (press F12)
- Beginner's curiosity and patience
Cost: $0. Everything needed is free.
Time commitment: 2-3 hours for complete tutorial. Take breaks. Learning happens between sessions.
Understanding the Canvas
SVG coordinate system explained:
(0,0) ────────────────→ X-axis increases
│
│
│
│
↓
Y-axis increases
Key concept: Origin (0,0) is top-left, not bottom-left like math class. Y increases downward.
Example:
- Point (100, 50) is 100 pixels right, 50 pixels down from top-left
- Point (200, 200) is 200 pixels right, 200 pixels down
This trips up beginners constantly. Remember: Y-axis is flipped compared to math.
Your First SVG: Hello Rectangle
Type this exactly (don't copy-paste):
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">
<rect x="50" y="50" width="200" height="100" fill="blue"/>
</svg>
Save as: first-svg.html
(not .txt!)
Open in browser. You should see a blue rectangle!
Understanding each part:
<svg>
: Container telling browser "this is vector graphics"
xmlns="..."
: XML namespace (always include exactly as written, don't worry about meaning yet)
width="300" height="200"
: Canvas size (300 pixels wide, 200 tall)
<rect>
: Rectangle shape
x="50" y="50"
: Rectangle starts 50px from left, 50px from top
width="200" height="100"
: Rectangle is 200px wide, 100px tall
fill="blue"
: Color (try changing to "red", "green", "#FF6B6B")
Congratulations! You created your first SVG from scratch.
Experiment: Change numbers, see what happens. Change x to 100. Change fill to "purple". Break things intentionally—errors teach.
Use our svg creator to see visual previews while learning code structure.
Project 1: Traffic Light
Goal: Create simple traffic light with three colored circles.
Step 1: Set up canvas
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="400">
</svg>
Canvas is 200px wide (narrow), 400px tall (tall for stacking lights).
Step 2: Add background rectangle (optional but nice)
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="400">
<rect x="50" y="50" width="100" height="300" fill="#333" rx="10"/>
</svg>
New attribute: rx="10"
= rounded corners (10px radius). Try different values.
Step 3: Add red light (top)
<circle cx="100" cy="100" r="30" fill="red"/>
cx="100" cy="100"
: Circle center at (100, 100)
r="30"
: Radius 30 pixels
fill="red"
: Red color
Step 4: Add yellow light (middle)
<circle cx="100" cy="200" r="30" fill="yellow"/>
Same x-position (100), different y-position (200).
Step 5: Add green light (bottom)
<circle cx="100" cy="300" r="30" fill="green"/>
Complete traffic light:
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="400">
<!-- Background -->
<rect x="50" y="50" width="100" height="300" fill="#333" rx="10"/>
<!-- Lights -->
<circle cx="100" cy="100" r="30" fill="red"/>
<circle cx="100" cy="200" r="30" fill="yellow"/>
<circle cx="100" cy="300" r="30" fill="green"/>
</svg>
Save, refresh browser. You have a traffic light!
Challenges (try yourself):
- Make lights bigger (change
r
) - Add black border to lights (add
stroke="black" stroke-width="2"
) - Position traffic light in different spot (change
x
,cy
values)
Learn comprehensive basics in how to create SVG files guide for complete SVG fundamentals.
Understanding Basic Shapes
Rectangle (<rect>
)
Syntax:
<rect x="X" y="Y" width="W" height="H" fill="COLOR"/>
Attributes:
- x, y: Top-left corner position
- width, height: Dimensions
- fill: Color
- rx, ry: Corner radius (optional, for rounded corners)
Example: Door
<rect x="150" y="200" width="100" height="200" fill="#8B4513" rx="5"/>
Circle (<circle>
)
Syntax:
<circle cx="CX" cy="CY" r="R" fill="COLOR"/>
Attributes:
- cx, cy: Center position
- r: Radius
- fill: Color
Example: Sun
<circle cx="50" cy="50" r="30" fill="yellow"/>
Ellipse (<ellipse>
)
Syntax:
<ellipse cx="CX" cy="CY" rx="RX" ry="RY" fill="COLOR"/>
Attributes:
- cx, cy: Center position
- rx: Horizontal radius
- ry: Vertical radius
Example: Egg
<ellipse cx="100" cy="150" rx="40" ry="60" fill="white" stroke="black"/>
Line (<line>
)
Syntax:
<line x1="X1" y1="Y1" x2="X2" y2="Y2" stroke="COLOR" stroke-width="WIDTH"/>
Attributes:
- x1, y1: Start point
- x2, y2: End point
- stroke: Line color
- stroke-width: Line thickness
Example: Stick
<line x1="100" y1="100" x2="200" y2="200" stroke="black" stroke-width="3"/>
Note: Lines have no fill
, only stroke
.
Polyline (<polyline>
)
Connected lines:
<polyline points="10,10 50,50 10,90 50,130" fill="none" stroke="blue" stroke-width="2"/>
Attributes:
- points: Comma/space-separated x,y pairs
- fill: Usually "none" for open lines
- stroke: Line color
Polygon (<polygon>
)
Closed shape:
<polygon points="100,50 150,150 50,150" fill="green"/>
Difference from polyline: Automatically closes (connects last point to first).
Example: Triangle
<polygon points="150,50 200,150 100,150" fill="red"/>
Discover icon creation in create SVG icons guide for systematic shape usage.
Project 2: Simple House
Goal: Combine basic shapes into recognizable house.
Step-by-step construction:
1. Set up canvas:
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">
</svg>
2. Add sky background:
<rect width="400" height="200" fill="#87CEEB"/>
Full width (400), half height (200), sky blue.
3. Add ground:
<rect y="200" width="400" height="200" fill="#90EE90"/>
Starts at y="200" (bottom half), green.
4. Add house body:
<rect x="150" y="150" width="100" height="100" fill="#DEB887"/>
Positioned in middle-ish area, tan/beige color.
5. Add roof (triangle):
<polygon points="150,150 200,100 250,150" fill="#8B4513"/>
Three points forming triangle above house body.
6. Add door:
<rect x="180" y="200" width="40" height="50" fill="#8B4513"/>
Centered on house body, brown.
7. Add window:
<rect x="165" y="170" width="20" height="20" fill="#ADD8E6"/>
Light blue window.
Complete house:
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">
<!-- Sky -->
<rect width="400" height="200" fill="#87CEEB"/>
<!-- Ground -->
<rect y="200" width="400" height="200" fill="#90EE90"/>
<!-- House body -->
<rect x="150" y="150" width="100" height="100" fill="#DEB887"/>
<!-- Roof -->
<polygon points="150,150 200,100 250,150" fill="#8B4513"/>
<!-- Door -->
<rect x="180" y="200" width="40" height="50" fill="#8B4513"/>
<!-- Window -->
<rect x="165" y="170" width="20" height="20" fill="#ADD8E6"/>
</svg>
Save, refresh. You have a house!
Challenges:
- Add second window (copy window rect, change x position)
- Add chimney (small rectangle on roof)
- Add sun (circle in sky)
- Add tree beside house (rectangle trunk, circle foliage)
Experiment freely. Can't break anything permanently—just refresh to start over.
Learn illustration techniques in create SVG illustrations guide for complex compositions.
Understanding the Path Element
<path>
is most powerful SVG element. Creates any shape imaginable. Also most complex initially.
Path Commands Basics
Path syntax:
<path d="COMMANDS" fill="COLOR"/>
The d
attribute contains drawing commands.
Core commands:
M (Move to): Pick up pen, move to position
<path d="M 50,50"/>
Moves to (50, 50). Doesn't draw anything yet.
L (Line to): Draw straight line
<path d="M 50,50 L 100,100"/>
Move to (50,50), draw line to (100,100).
Z (Close path): Draw line back to start
<path d="M 50,50 L 100,50 L 75,100 Z" fill="red"/>
Creates closed triangle.
Project 3: Arrow Using Paths
Goal: Create simple arrow shape.
Step 1: Plan shape
Arrow has:
- Straight shaft (rectangle-ish)
- Pointed tip (triangle)
Step 2: Draw with path
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">
<path d="M 50,90 L 180,90 L 180,70 L 230,100 L 180,130 L 180,110 L 50,110 Z" fill="blue"/>
</svg>
Understanding the commands:
- M 50,90: Start at left side of shaft
- L 180,90: Draw to right side of shaft (top edge)
- L 180,70: Draw up to create arrow tip
- L 230,100: Draw to point of arrow
- L 180,130: Draw down to bottom of tip
- L 180,110: Draw to bottom edge of shaft
- L 50,110: Draw back to left (bottom edge)
- Z: Close path back to start
Result: Arrow pointing right.
Challenges:
- Change colors
- Rotate arrow by changing coordinates
- Make arrow bigger (multiply all numbers by 1.5)
Curves with Path
Q (Quadratic Bezier curve):
<path d="M 50,100 Q 100,50 150,100" stroke="blue" stroke-width="2" fill="none"/>
- Start at (50, 100)
- Control point at (100, 50) - "pulls" curve toward this point
- End at (150, 100)
Result: Curved line (smile shape).
C (Cubic Bezier curve): More control, two control points
<path d="M 50,100 C 75,50 125,50 150,100" stroke="red" stroke-width="2" fill="none"/>
Bezier curves enable organic shapes. Don't worry about mastering immediately—practice makes comfortable.
Discover background patterns in create SVG backgrounds guide for pattern creation.
Adding Style and Polish
Stroke (Outlines)
Add borders to shapes:
<circle cx="100" cy="100" r="50" fill="yellow" stroke="black" stroke-width="3"/>
Attributes:
- stroke: Outline color
- stroke-width: Thickness (in pixels)
Opacity and Transparency
Make shapes see-through:
<circle cx="100" cy="100" r="50" fill="blue" opacity="0.5"/>
opacity
: 0 (invisible) to 1 (solid). 0.5 = 50% transparent.
Individual color opacity:
<circle cx="100" cy="100" r="50" fill="rgba(255,0,0,0.5)"/>
rgba: Red, Green, Blue, Alpha (transparency).
Grouping with <g>
Organize related elements:
<g id="tree">
<rect x="90" y="150" width="20" height="50" fill="#8B4513"/>
<circle cx="100" cy="130" r="30" fill="green"/>
</g>
Benefits:
- Logical organization
- Apply properties to entire group
- Easier to move/transform group
Adding Text
<text x="100" y="50" font-size="24" fill="black" text-anchor="middle">
Hello SVG!
</text>
Attributes:
- x, y: Position (baseline of text)
- font-size: Size in pixels
- text-anchor: Alignment (start, middle, end)
Project 4: Smiley Face
Goal: Friendly face combining everything learned.
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300">
<!-- Face circle -->
<circle cx="150" cy="150" r="100" fill="yellow" stroke="black" stroke-width="3"/>
<!-- Left eye -->
<circle cx="120" cy="130" r="10" fill="black"/>
<!-- Right eye -->
<circle cx="180" cy="130" r="10" fill="black"/>
<!-- Smile (curved path) -->
<path d="M 110,170 Q 150,200 190,170" stroke="black" stroke-width="3" fill="none"/>
<!-- Optional: Nose -->
<circle cx="150" cy="155" r="5" fill="black"/>
</svg>
Result: Classic smiley face!
Challenges:
- Change expression (adjust smile curve)
- Add eyebrows (two short lines above eyes)
- Change colors (different face color, rosy cheeks)
- Add hair (circle with different color at top)
Common Beginner Mistakes
Mistake 1: Forgetting Closing Tags
Wrong:
<rect x="10" y="10" width="50" height="50" fill="blue">
Right:
<rect x="10" y="10" width="50" height="50" fill="blue"/>
SVG uses self-closing tags for shapes (note the />
).
Mistake 2: Wrong Coordinate System
Thinking Y increases upward (like math) when it actually increases downward.
If shape appears "upside down," remember: Y-axis is flipped from math class.
Mistake 3: Forgetting fill
for Paths
Path without fill:
<path d="M 10,10 L 50,50" stroke="black"/>
Shows only line (because no fill
).
To fill shape:
<path d="M 10,10 L 50,50 L 10,50 Z" fill="red"/>
Add fill
attribute AND close path with Z
.
Mistake 4: Typos in Attributes
Wrong: color="red"
(not a valid SVG attribute)
Right: fill="red"
or stroke="red"
SVG uses fill
and stroke
, not color
.
Next Steps
Practice Projects
Try creating these yourself:
- Robot face: Rectangle head, circle eyes, rectangle mouth
- Car: Two circles (wheels), rectangle (body), polygon (roof)
- Flower: Circle center, ellipses as petals arranged in circle
- Simple logo: Your initials using basic shapes
Don't peek at solutions immediately—struggle builds understanding.
Learning More
When comfortable with basics:
- Gradients: Add depth with color transitions
- Patterns: Create repeating backgrounds
- Animations: Make shapes move
- Filters: Add effects like shadows and blurs
Resources:
- MDN SVG Documentation
- SVG specification (W3C)
- Our comprehensive how to create SVG files guide
Using Visual Tools
After understanding code:
Visual tools (svg creator, Figma, Illustrator) accelerate creation. But understanding code enables:
- Troubleshooting exports
- Manual optimization
- Programmatic generation
- Deeper customization
Recommended workflow:
- Learn basics hand-coding (this tutorial)
- Graduate to visual tools for speed
- Return to code for optimization and tweaking
Frequently Asked Questions
Q1: Do I need to memorize all path commands?
A: No. Learn M (move), L (line), Z (close) first. Reference others as needed. Even professionals look up syntax regularly. Understanding concepts matters more than memorization.
Q2: Why learn code when visual tools exist?
A: Understanding code provides: problem-solving ability, optimization control, programmatic generation capability, and deeper comprehension. You'll be more effective even when using visual tools.
Q3: How long until I'm comfortable creating SVG from scratch?
A: Basic shapes: 2-4 hours practice. Complex paths: 10-20 hours. Comfort with most tasks: 40-60 hours over several weeks. Like any skill, consistent practice beats intensive cramming.
Q4: What if my SVG doesn't display correctly?
A: Check: (1) Valid XML syntax (closed tags, quotes around attributes), (2) Correct coordinate values (within canvas bounds), (3) Required attributes present (e.g., path needs d
attribute), (4) Browser console for errors (F12 > Console tab).
Q5: Can I create professional graphics hand-coding?
A: Yes, but slower than visual tools for complex work. Hand-coding excels for: simple shapes, programmatic generation, learning, and understanding. For detailed illustrations, use visual tools then optimize code.
Q6: Should I use absolute or relative path commands?
A: Absolute (uppercase M, L, etc.) easier for beginners—coordinates are exact positions. Relative (lowercase m, l, etc.) more compact but require calculating relative positions. Start with absolute, learn relative later if desired.
Q7: How do I center something in the SVG canvas?
A: For circle: cx
= canvas width / 2, cy
= canvas height / 2. For rectangle: x
= (canvas width - rect width) / 2, y
= (canvas height - rect height) / 2. Example: 200px canvas, 50px circle → cx="100" cy="100".
Q8: Where can I find color codes for fill
attribute?
A: Use named colors ("red", "blue", "green") for simplicity. For specific colors, use hex codes from color pickers (Google "color picker") like #FF6B6B
. Or use our svg creator and examine generated colors.
Conclusion: You Can Create SVG from Scratch
You've progressed from zero knowledge to creating recognizable graphics using only text editor and browser. You understand coordinate systems, basic shapes, paths, styling, and composition. This foundation enables everything else in SVG.
Creating SVG from scratch teaches how vector graphics actually work—knowledge that applies whether hand-coding, using visual tools, or troubleshooting exported files. Every professional SVG creator benefits from understanding these fundamentals.
Continue practicing, experiment freely (breaking things teaches), and gradually increase complexity. The confidence from creating graphics with nothing but code is uniquely empowering.
Our svg creator provides visual feedback while learning, generating clean code you can study. Experience how understanding code and using tools complement each other.
Ready to continue learning? Explore our create svg files platform for comprehensive tutorials building on these fundamentals.
Continue your SVG journey: