🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

controls

AI & DATA SCIENCE // controls

The controls attribute on <video> or <audio> displays the browser's native playback UI — play/pause, seek bar, volume, and fullscreen (for video).

Syntax

<video controls>
  <source src="movie.mp4" type="video/mp4">
</video>

Deep Dive Course

**`controls`** is a boolean attribute — its mere presence turns it on, regardless of any value (`controls`, `controls="controls"`, and `controls="true"` all behave identically; only its ABSENCE means off). Without it, a `<video>` or `<audio>` element has no visible playback UI at all, and would only be controllable via custom JavaScript and your own buttons. The native controls' exact appearance varies by browser and OS, since each renders its own built-in UI rather than a standardized one.

1Understanding controls

`controls` is a boolean attribute — its mere presence turns it on, regardless of any value (controls, controls="controls", and controls="true" all behave identically; only its ABSENCE means off). Without it, a <video> or <audio> element has no visible playback UI at all, and would only be controllable via custom JavaScript and your own buttons. The native controls' exact appearance varies by browser and OS, since each renders its own built-in UI rather than a standardized one.

💡

If you need a custom-branded player UI instead of the browser's native controls, omit controls entirely and build your own buttons that call the media element's play()/pause() methods via JavaScript.

editor.html
<audio controls>
  <source src="/podcast.mp3" type="audio/mpeg">
</audio>
localhost:3000

2Practical Example

Here is a real-world application of controls showing how it is used in production HTML.

editor.html
<!-- No controls: fully custom playback via JavaScript -->
<video id="player" src="/clip.mp4"></video>
<button onclick="document.getElementById('player').play()">Play</button>
localhost:3000

3Best Practices

Follow these guidelines when working with controls:

1. Include controls by default so users always have a way to pause/adjust volume

2. Only omit it if you're deliberately building fully custom playback controls with JavaScript

3. Remember native control appearance differs across browsers — don't assume pixel-perfect consistency

⚠️

Tip: If you need a custom-branded player UI instead of the browser's native controls, omit controls entirely and build your own buttons that call the media element's play()/pause() methods via JavaScript.

editor.html
<audio controls>
  <source src="/podcast.mp3" type="audio/mpeg">
</audio>
localhost:3000

Examples

Example 01Basic Usage
<audio controls>
  <source src="/podcast.mp3" type="audio/mpeg">
</audio>
Example 02Advanced Example
<!-- No controls: fully custom playback via JavaScript -->
<video id="player" src="/clip.mp4"></video>
<button onclick="document.getElementById('player').play()">Play</button>

Best Practices

  • Include controls by default so users always have a way to pause/adjust volume
  • Only omit it if you're deliberately building fully custom playback controls with JavaScript
  • Remember native control appearance differs across browsers — don't assume pixel-perfect consistency

Interview Question

What's the difference between controls, controls="controls", and controls="false" on a <video> element?

Hint: Think about how HTML boolean attributes are actually evaluated.

controls is a boolean attribute, meaning its presence alone enables it — the actual attribute VALUE is irrelevant to the browser's parser. controls, controls="controls", and even controls="false" all enable the controls, because in all three cases the attribute is simply present. To disable it, you must omit the attribute entirely, not set it to any particular string value.

Exercises

EasyPractice using controls in a real scenario.
View Solution
<audio controls>
  <source src="/podcast.mp3" type="audio/mpeg">
</audio>

Frequently Asked Questions

What's the difference between controls, controls="controls", and controls="false" on a <video> element?

controls is a boolean attribute, meaning its presence alone enables it — the actual attribute VALUE is irrelevant to the browser's parser. controls, controls="controls", and even controls="false" all enable the controls, because in all three cases the attribute is simply present. To disable it, you must omit the attribute entirely, not set it to any particular string value.

Related Functions

video-tagaudio-tag