Skip to main content

🗓️ 21062025 1648
📎

svg_path_model

Path-Based Mental Model

  • SVG uses a path model: shapes are defined by outlines (paths), then styled.
  • Every shape is a path that can be:
    • Filled (fill) to color the interior
    • Stroked (stroke) to outline the shape

Fill Attributes

AttributeDescriptionNotes
fillColor used to fill the interior of a shapeDefaults to black
fill="none"Makes the shape transparentMust be explicitly set
currentColorInherits text color from parent HTMLOnly works with inline SVGs
  • Accepts all valid CSS color formats (e.g. red, #ff0000, hsl(...))

Stroke Attributes

AttributeDescriptionNotes
strokeColor of the shape's outlineAccepts any CSS color, including currentColor
stroke-widthThickness of the outlineMeasured in SVG units
stroke-dasharrayPattern of dashes for the outlineE.g. 5 3 for dashed lines
stroke-dashoffsetOffset where the dash pattern beginsUseful for animation effects
stroke-linecapStyle of line ends (butt, round, square)Only for open paths or lines
stroke-linejoinStyle of corners where paths meet (miter, round, bevel)Affects sharp corners
stroke-miterlimitLimits sharpness of miter joinsOnly applies if stroke-linejoin=miter

Drawing Order & Stacking

ConceptBehavior
DOM orderDetermines which shape appears on top
z-indexIgnored in SVGs
ManipulationMove element later in code to bring forward

References