大网数据广告活动
Web 标准与前端开发

`:muted` CSS pseudo-class

· 52CE 我爱测

The **`:muted`** CSS pseudo-class selector represents an element that is capable of making sound, such as audio or video, but is muted (forced silent).

The :muted CSS pseudo-class selector represents an element that is capable of making sound, such as audio or video, but is muted (forced silent).

Muted is different from :volume-locked in that the page author has control over whether a media element can be muted or un-muted. User agents may set media muted value according to use preferences (e.g., remembering the last set value across sessions, on a per-site basis, or otherwise). An element that is :volume-locked cannot be muted, un-muted, or have its volume changed via JavaScript because of an operating system or user agent preference.

Syntax

:muted {
  /* ... */
}

Examples

HTML

The muted attribute is added to the video element so that the sound is muted, this works the same for audio elements.



<video
  controls
  muted
  src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
  poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
  width="620">
  Sorry, your browser doesn't support embedded videos, but don't worry, you can
  <a href="https://archive.org/details/BigBuckBunny_124">download it</a>
  and watch it with your favorite video player!
</video>

CSS

If the <video> element is muted then a red outline is drawn around it, when it is not muted then it has a green outline. Try toggling the mute icon in the controls to see the state change.

video {
  margin: 5px;
}
video:muted {
  outline: 5px solid red;
}

video:not(:muted) {
  outline: 5px solid green;
}

examples

Specifications

Browser compatibility

See also

  • :buffering
  • :paused
  • :playing
  • :seeking
  • :stalled
  • :volume-locked
  • CSS selectors
  • muted property of HTMLMediaElement objects

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。