color

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Das color-Attribut wird verwendet, um einen potenziellen indirekten Wert, currentcolor, für die Attribute fill, stroke, stop-color, flood-color und lighting-color bereitzustellen.

Hinweis: Als Präsentationsattribut hat color auch ein entsprechendes CSS-Eigenschafts-Pendant: color. Wenn beide angegeben sind, hat die CSS-Eigenschaft Vorrang.

Technisch gesehen kann color auf jedes Element angewendet werden, hat jedoch keine direkte Auswirkung auf SVG-Elemente.

Nutzungshinweise

Wert <color> | inherit
Standardwert Abhängig vom User-Agent
Animierbar Ja

Beispiel

html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <g color="green">
    <rect width="50" height="50" fill="currentcolor" />
    <circle
      r="25"
      cx="70"
      cy="70"
      stroke="currentcolor"
      fill="none"
      stroke-width="5" />
  </g>
</svg>

Spezifikationen

Specification
CSS Color Module Level 4
# the-color-property
Scalable Vector Graphics (SVG) 2
# ColorProperty

Browser-Kompatibilität

BCD tables only load in the browser

Siehe auch