Use SVG view box instead of width and height

Using viewBox improves maintainability.

Status
accepted
Date
Contributors
Andrew Berry, Andy Blum, Chris DeLuca
Topics
front-end performance

Decision

Include the viewBox property on <svg> elements.

Omit the width and height properties from <svg> elements.

Exceptions

User uploaded SVGs are except from this standard.

Consequences

SVG elements will have a defined bounding canvas, which will make them easier to size. Maintenance will be easier, as all width and height information will be grouped in a single domain, CSS.

Search Decisions