Spec-Zone.ru › SVG

media

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨January 2020⁩.

  • Learn more
  • See full compatibility
  • Report feedback

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

You can use this attribute with the following SVG elements:

  • <style>

Example

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

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

Usage notes

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

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.

Specifications

Specification
Scalable Vector Graphics (SVG) 2>
# StyleElementMediaAttribute>

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
media 1 79 1.5 15 3 18 4 14 2 1.0 4.4 2

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/media

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API