The media attribute specifies a media query that must be matched for a style sheet to apply.

Only one element is using this attribute: <style>

<svg viewBox="0 0 240 220" xmlns="http://www.w3.org/2000/svg">
    rect { fill: black; }
  <style media="all and (min-width: 600px)">
    rect { fill: seagreen; }

  <text y="15">Resize the window to see the effect</text>
  <rect y="20" width="200" height="200" />

Usage notes

Value <media-query-list>
Default value all
Animatable Yes

This value holds a media query that needs to match in order for the style sheet to be applied.

If not specified, the style sheet is applied unconditionally.


Specification Status Comment
Scalable Vector Graphics (SVG) 2
The definition of 'media' in that specification.
Candidate Recommendation Changed the value definition from different media types as defined in CSS 2 to <media-query-list>.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'media' in that specification.
Recommendation Initial definition

Browser compatibilityUpdate compatibility data on GitHub

Chrome Edge Firefox Internet Explorer Opera Safari
media ? ? ? ? ? ?
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
media ? ? ? ? ? ?

© 2005–2020 Mozilla and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.