HTML <video> style Attribute

A style attribute on a <video> tag assigns a unique style to the video control.

Its value is CSS that defines the appearance of the video element.



A style attribute on a <video> element.

<video class="video" controls 
       style="width:300px; height:240px; outline:none;
              border: 5px solid #45c9d0; padding: 10px;">
  <source src="/media/movie.mp4" type="video/mp4">
  <source src="/media/movie.ogg" type="video/ogg">

Using style

The style attribute specifies the style, i.e. look and feel, of the <video> element.

A style contains any number of CSS property/value pairs, separated by semicolons (;).

The style attribute overrides any other style that was defined in a <style> tag or an external CSS file.

This inline styling affects the current <video> element only.


<video style="CSS-styles">



Value Description
CSS-styles One or more CSS property/value pairs separated by semicolons (;).

More Examples

A style attribute on a <video> element.
Clicking the button toggles the video size.

<video id="myvideo" controls
       style="width: 320px; height: 240px; outline: none;">
  <source src="/media/movie.mp4" type="video/mp4">
  <source src="/media/movie.ogg" type="video/ogg">

<button onclick="toggle();">Toggle class</button>

  let toggle = () => {
     let element = document.getElementById("myvideo");
     if ( === "320px") { = "480px"; = "360px";
     } else { = "320px"; = "240px";

Code explanation

The style attribute assigns width and height to the <video>.

Clicking the button calls JavaScript which changes the element width and height.

Browser support

Here is when style support started for each browser:

4.0 Jan 2010
3.5 Jun 2009
9.0 Sep 2012
10.5 Mar 2010
4.0 Jun 2009

You may also like

 Back to <video>

Last updated on Sep 30, 2023