Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

SVG Basics | HTML Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. HTML Course

Lesson 15 of 55

·HTML

SVG Basics

10 min

Course progress27%

What you'll learn

Keep these ideas in mind as you work through the lesson.

5 points
  • SVG as XML markup for resolution‑independent graphics
  • Common shape elements (`<circle>`, `<rect>`, `<path>`)
  • Coordinate system via `viewBox` and the importance of `preserveAspectRatio`
  • Styling and theming SVG with CSS variables
  • Accessibility guidelines: `<title>`, `<desc>`, `aria-hidden`
  • Scalable Vector Graphics (SVG)

    <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>
    

    Core concepts

    • <svg> container defines a coordinate system via viewBox (min-x min-y width height).
    • Shapes: <rect>, <circle>, <ellipse>, <line>, <polygon>, <path>.
    • <text> allows labeling directly inside the graphic; use text-anchor for alignment.
    • Inline SVG can be styled with CSS (fill, stroke, opacity) and animated via SMIL or CSS @keyframes.
    • CSS var(--color-primary) can be used inside SVG styles for easy theming.

    Accessibility

    • Add a <title> and <desc> inside the SVG for screen readers.
    • When the SVG is decorative, add aria-hidden='true'.
    • Use focusable='false' to prevent keyboard focus on decorative graphics.

    Quick checklist for SVG

    1. viewBox set for responsive scaling? ✅
    2. <title>/<desc> provided for meaning? ✅
    3. Styling done via CSS, not inline fill where possible? ✅
    4. Decorative icons hidden from assistive tech (aria-hidden)? ✅
    5. Tested with a screen reader for correct description? ✅

    Tip: Use <use> with an external SVG sprite sheet to reduce duplicate markup and improve caching.

    Make it stickPractice what you've learned1 quiz · 2 practical tests · Optional activities from HTML CourseBrowse activities
    Previous lessonCanvas 2D API – Shapes and PathsContinue to lesson 16Using CSS with HTML – `<link>` and `<style>`Back to HTML Course curriculum