SVG viewBox 0 0 24 24 Coordinate System Explained

Setting the attribute viewBox="0 0 24 24" on an SVG defines an internal 24-by-24 unit coordinate canvas that acts as the reference frame for all nested paths and shapes. This configuration decouples the artwork’s internal dimensions from the actual display size on a screen, allowing the icon to scale infinitely without distortion while maintaining consistent visual proportions across entire user interface icon sets.

Deconstructing the viewBox Values

The viewBox attribute accepts four numeric parameters: min-x, min-y, width, and height. When written as viewBox="0 0 24 24", the values map as follows:

Any coordinate referenced in a path command—such as M 12 12—is calculated relative to this 24x24 grid, where (0, 0) is the top-left corner and (24, 24) is the bottom-right corner.

Separating Internal Coordinates from Render Size

The primary function of the viewBox is separating the internal coordinate space (the drawing canvas) from the external viewport (the physical display size defined by CSS or HTML width and height attributes).

When you change the CSS dimensions of an SVG with viewBox="0 0 24 24" from 24px to 120px, the browser scales the entire internal 24x24 coordinate system uniformly to fill the new container. The path data (<path d="..." />) never needs to be recalculated or rewritten, as the browser automatically handles the vector scaling math based on the ratio between the viewBox and the rendered viewport.

Why 24x24 Is the Industry Standard

The 24x24 coordinate system has become the baseline for major design systems (including Material Design, Feather, and Lucide) for several structural reasons: