Video controls attribute

Definition and usage

controls The attribute sets or returns whether the standard video controls should be displayed.

This attribute indicates <video> controls attribute.

If this attribute is set, it specifies that the video controls should be displayed.

The video controls should include:

  • Play
  • Pause
  • Search
  • Volume
  • Switch to full screen
  • Subtitles (available when)
  • Track (available when)

Instance

Example 1

Enable video controls:

document.getElementById("myVideo").controls = true;

Try it yourself

Example 2

Check if the video controls are displayed:

var x = document.getElementById("myVideo").controls;

Try it yourself

Example 3

Enable, disable, and check the status of controls:

var x = document.getElementById("myVideo");
function enableControls() { 
  x.controls = true;
  x.load();
} 
function disableControls() { 
  x.controls = false;
  x.load();
} 
function checkControls() { 
  alert(x.controls);
}

Try it yourself

Syntax

Return the controls attribute:

videoObject.controls

Set the controls attribute:

videoObject.controls = true|false

attribute value

value description
true|false

Définit si les contrôles doivent être affichés pour la vidéo.

  • true - indique que les contrôles sont affichés
  • false - par défaut. Indique que les contrôles ne sont pas affichés

Détails techniques

Valeur de retour : Valeur booléenne, renvoie true si les contrôles de la vidéo sont affichés ; sinon renvoie false.
Valeur par défaut : false

Support du navigateur

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 9.0 Support Support Support

Pages associées

Manuel de référence HTML :Propriété controls de l'élément <video> HTML