Lesson 15 of 55
HTMLSVG Basics
10 min
Course progress27%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 15 of 55
HTML10 min
Keep these ideas in mind as you work through the lesson.
<svg width='200' height='200' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'>
<circle cx='50' cy='50' r='40' fill='green' stroke='black' stroke-width='2' />
<text x='50' y='55' font-size='12' text-anchor='middle' fill='white'>SVG</text>
</svg>
<svg> container defines a coordinate system via viewBox (min-x min-y width height).<rect>, <circle>, <ellipse>, <line>, <polygon>, <path>.<text> allows labeling directly inside the graphic; use text-anchor for alignment.fill, stroke, opacity) and animated via SMIL or CSS @keyframes.var(--color-primary) can be used inside SVG styles for easy theming.<title> and <desc> inside the SVG for screen readers.aria-hidden='true'.focusable='false' to prevent keyboard focus on decorative graphics.viewBox set for responsive scaling? ✅<title>/<desc> provided for meaning? ✅fill where possible? ✅aria-hidden)? ✅Tip: Use
<use>with an external SVG sprite sheet to reduce duplicate markup and improve caching.