| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/API/MediaList | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since July 2015.
The MediaList interface represents the media queries of a stylesheet, e.g., those set using a <link> element's media attribute.
Note:
MediaList is a live list; updating the list using properties or methods listed below will immediately update the behavior of the document.
MediaList.mediaTextA stringifier that returns a string representing the MediaList as text, and also allows you to set a new MediaList.
MediaList.length Read onlyReturns the number of media queries in the MediaList.
MediaList.appendMedium()Adds a media query to the MediaList.
MediaList.deleteMedium()Removes a media query from the MediaList.
MediaList.item()A getter that returns a string representing a media query as text, given the media query's index value inside the MediaList. This method can also be called using the bracket ([]) syntax.
MediaList.toString()Returns a string representation of this media list in the same format as the object's MediaList.mediaText property.
The following would log to the console a textual representation of the MediaList of the first stylesheet applied to the current document.
const stylesheets = document.styleSheets;
let stylesheet = stylesheets[0];
console.log(stylesheet.media.mediaText);
| Specification |
|---|
| CSS Object Model (CSSOM) # the-medialist-interface |
This page was last modified on Jun 24, 2025 by MDN contributors.
MediaListCSSCSSConditionRuleCSSFontFeatureValuesMapCSSFontFeatureValuesRuleCSSFontPaletteValuesRuleCSSFunctionDeclarationsCSSFunctionDescriptorsCSSFunctionRuleCSSGroupingRuleCSSImportRuleCSSKeyframeRuleCSSKeyframesRuleCSSLayerBlockRuleCSSLayerStatementRuleCSSMediaRuleCSSNamespaceRuleCSSPageDescriptorsCSSPageRuleCSSPropertyRuleCSSRuleCSSRuleListCSSStartingStyleRuleCSSStyleDeclarationCSSStylePropertiesCSSStyleRuleCSSStyleSheetCSSSupportsRuleCaretPositionMediaQueryListScreenStyleSheetStyleSheetListYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |