Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
<style>

Defines a CSS stylesheet for the document.

Multiple <style> elements may be defined in a single document, and the aggregate document style is computed from that using CSS cascading rules.

Stylesheet syntax is parsed using CSS Syntax Level 3: https://www.w3.org/TR/css-syntax-3/

The <style> element is SVG's native way to embed a CSS stylesheet directly in the document

  • the counterpart of HTML's <style> tag. Rules inside it use supported CSS selectors, including element, class, id, attribute, and structural pseudo-class selectors such as :nth-child. They can set supported SVG presentation properties such as fill, stroke, stroke-width, opacity, font-family, and transform. A single document may contain multiple <style> elements; Donner combines them using the CSS cascade, so later rules and more specific selectors can override earlier ones.

Use <style> to share static visual properties across many shapes or keep presentation separate from structure. User-action pseudo-classes such as :hover and CSS keyframe animations are not currently supported. For one-off styling, the inline style="..." attribute on an individual element is usually simpler.

<style>   .rect {     fill: crimson;     stroke: darkred;   }   .circle:nth-child(3n+1) { fill: red; }   .circle:nth-child(3n+2) { fill: limegreen; }   .circle:nth-child(3n+3) { fill: blue; } </style>

Attribute Default Description
type text/css Type of the stylesheets contents, currently only text/css is supported.
media (empty) [unsupported] Specifies a media query that must be matched for the style sheet to apply.
title (empty) [unsupported] Specifies a title for the style sheet, which is used when selecting between alternate style sheets.

Note that type is defined to be a media type [rfc2046].

Children

Either text or CDATA nodes are allowed as child nodes.