« SVG Attribute reference home
该属性指定了当前元素的样式信息。style属性指定了单个元素的样式信息。 <SVG>元素内联样式规则的样式表语言由contentStyleType 属性指定。
使用环境
| Categories | Presentation attribute |
|---|---|
| Value | <style> |
| Animatable | No |
| Normative document | SVG 1.1 (2nd Edition) |
- <style>
- 样式数据的语法取决于样式表语言。默认情况下,如果未指定
contentStyleType,样式表语言为CSS。
示例
以下示例展示了使用CSS作为样式表语言来使用style属性,为一个矩形框添加样式。
<svg version="1.1" viewbox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg">
<rect height="300" width="600" x="200" y="100"
style="fill: red; stroke: blue; stroke-width: 3"/>
</svg>
元素
以下元素可以使用style属性
- Container elements »
- Filter primitive elements »
- Gradient elements »
- Graphics elements »
- Structural elements »
- Text content elements »
<clipPath><filter><font><foreignObject><glyphRef><stop><glyph>