style

style attribute allows to style an element using CSS declarations. It functions identically to the style attribute in HTML .

You can use this attribute with any SVG element.

范例

<svg viewbox="0 0 100 60" xmlns="http://www.w3.org/2000/svg">
  <rect width="80"  height="40" x="10" y="10"
      style="fill: skyblue; stroke: cadetblue; stroke-width: 2;"/>
</svg>

					

用法注意事项

<style>
默认值 None
Animatable No
<style>

The syntax of style data depends on the style sheet language. By default, the style sheet language is CSS .

注意: In theory, the contentStyleType 属性 could be used to specify styling languages other than CSS, like XSL(T) . However, this was never implemented satisfactorily in browsers, so you should not rely on it.

规范

规范 状态 注释
Scalable Vector Graphics (SVG) 2
The definition of 'style' in that specification.
候选推荐 无变化
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'style' in that specification.
推荐 初始定义

浏览器兼容性

BCD tables only load in the browser

另请参阅

Found a problem with this page?

最后修改: , 由 MDN 贡献者