HTML controls Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The controls attribute on <video> or <audio> is a boolean flag. When present, the browser shows its built-in playback UI (play/pause, seek, volume, and often fullscreen on video).

Without controls, there is no default UI — users cannot play the media unless you add custom buttons with JavaScript. Pair with src (or <source>), and optionally poster, loop, or muted.

Baseline · Widely available.

Not deprecated and not experimental. Standard media attribute across modern browsers. Exact control chrome looks different per browser.

HTML Syntax

syntax.html
<video  controls src="…"></video>

Same boolean form on <audio>. Presence turns controls on; no value is required (controls="controls" is also valid).

Attribute Values

Boolean attribute — only presence matters:

ValueDescriptionTry it
(present)Show the browser’s default media controlsTry it
(absent)No default UI — needs custom controls or scripted playTry it
On <audio>Makes the audio element visible with a control barTry it
With controlslistOptional hint to hide some native UI pieces when controls is on (support varies)Try it

Live Preview

Toggle controls on a real video. With controls off, the native play bar disappears.

Use the video’s play button when controls are on. When off, playback UI is hidden.

video

controls present

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Video with controls

Add the boolean attribute so users can play, pause, and seek.

HTML
<video controls width="320" playsinline>
  <source src="/video/count.mp4" type="video/mp4">
  <source src="/video/count.webm" type="video/webm">
  Your browser does not support the video element.
</video>
Try It Yourself

How It Works

  1. controls (present) asks for the browser’s default playback UI.
  2. source elements provide formats; the browser picks one it supports.
  3. Fallback text shows only if <video> is unsupported.
  4. playsinline helps mobile browsers play in-page instead of forcing fullscreen (where supported).

Example 2 — Audio with controls

Audio has little visible UI without controls — include it for a usable player.

HTML
<figure>
  <figcaption>Sample audio:</figcaption>
  <audio controls>
    <source src="/audio/count.mp3" type="audio/mpeg">
    <source src="/audio/count.ogg" type="audio/ogg">
    <a href="/audio/count.mp3">Download MP3</a>
  </audio>
</figure>
Try It Yourself

How It Works

  1. controls shows play, seek, and volume for audio.
  2. Multiple sources improve format coverage across browsers.
  3. Download link inside the element is useful fallback content.
  4. Caption with <figcaption> clarifies what the clip is.

Example 3 — Without controls (custom play)

Omitting controls hides the native bar. A simple button can call play().

HTML
<video id="demo" width="320" playsinline>
  <source src="/video/count.mp4" type="video/mp4">
</video>
<p>
  <button type="button" id="playBtn">Play / Pause</button>
</p>
<script>
  var v = document.getElementById("demo");
  document.getElementById("playBtn").addEventListener("click", function () {
    if (v.paused) v.play();
    else v.pause();
  });
</script>
Try It Yourself

How It Works

  1. No controls attribute — the native bar is not shown.
  2. Custom button uses the media element’s play() / pause() methods.
  3. You own the UX — add seek, mute, and captions yourself for a full player.
  4. For beginners, prefer native controls unless you need a custom design.

Edge Cases & Pitfalls

Default controls are the easiest accessible path — custom UIs need extra work.

a11y

Prefer native controls first

Browser controls are keyboard-operable out of the box. Custom players must reimplement focus, labels, and shortcuts carefully.

autoplay

Autoplay still has limits

autoplay with sound is often blocked. controls does not bypass that — mute or wait for a user gesture.

audio

Audio without controls is nearly invisible

An <audio> tag with no controls (and no custom UI) gives users nothing to click.

look

UI differs by browser

Icons and layout of the control bar are not identical in Chrome, Firefox, and Safari. Plan for that if branding must match.

JS

Toggle with .controls

In JavaScript: video.controls = true or false, or use setAttribute / removeAttribute.

Browser Support

controls is an HTML attribute for <video> and <audio> in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

controls

Widely available with HTML5 media. The presence of controls is consistent; the visual design of the bar varies by engine.

96% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet All modern
Full support
Internet Explorer IE9+ HTML5 media
Supported
controls Widely supported

Bottom line: Safe default for playable media. Use custom controls only when you need a branded player and can meet accessibility requirements.

Key Takeaways

  • Role: show the browser’s built-in media playback UI.
  • Elements: <video> and <audio> only.
  • Boolean: present = on; absent = no default bar.
  • Custom UI: omit controls and wire your own buttons with script.

One line: add controls so users can play media — omit it only when you supply your own UI.

Frequently Asked Questions

On video or audio, controls tells the browser to show its built-in playback UI — play/pause, seeking, and volume (and fullscreen on video where supported).
HTML media elements: video and audio. It does not apply to img, iframe, or other non-media tags.
Yes. Presence means show controls. Absence means the browser does not show its default control bar.
Users get no default play UI. You must play media with script (or custom buttons) via the HTMLMediaElement API, or users cannot start playback easily.
You can style the media element as a box (size, margin, border). Individual control buttons inside the native UI are not reliably styleable — use a custom player for full design control.
An optional hint (when controls is present) that can suggest hiding some UI pieces, such as download. Browser support varies.

Next: coords

Define clickable hotspots on an image map with area coordinates.

coords tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful