MDN’s new design is in Beta! A sneak peek:

我們的志工尚未將本文翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!
您也可以閱讀本文的 English (US) 版本。

« SVG Attribute reference home

The style attribute specifies style information for its element. It functions identically to the style attribute in HTML.

Usage context

Categories Presentation attribute
Value <style>
Animatable No
Normative document SVG 1.1 (2nd Edition)
The syntax of style data depends on the style sheet language. By default, the style sheet language is CSS.

Note: In theory, the contentStyleType attribute could be used to specify styling languages other than CSS, like XSL(T). However, this was never implemented satisfactorily in browsers, so do not rely on it.


The following example shows styling of a rectangle with the style attribute using CSS as style sheet language.

<svg viewbox="0 0 1000 500" xmlns="">
  <rect height="300" width="600" x="200" y="100" 
     style="fill: red; stroke: blue; stroke-width: 3"/>


The following elements can use the style attribute


 此頁面的貢獻者: Tigt, Jeremie, pa7
 最近更新: Tigt,