concept

Svg presentation attributes — CSS reference

Presentation attributes participate in the author cascade with specificity zero. An ordinary matching author style rule can override them. This rectangle retains its red attribute but paints blue.

Formal Syntax & Structure

css syntaxcss
<rect fill="red" class="icon"/>; .icon { fill: blue; }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>SVG presentation attributes</title><style>body{margin:0;background:white}svg{display:block}.icon{fill:blue}</style><body><svg xmlns="http://www.w3.org/2000/svg" width="240" height="160" viewBox="0 0 240 160" role="img" aria-label="SVG styling example"><rect id="a" class="icon" x="40" y="40" width="100" height="80" fill="red"/></svg></body></html>
CSS Reference