HTML Videos

## HTML Basic

HTML HOME HTML Introduction HTML Editors HTML Basic HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Formatting HTML Links HTML Head HTML CSS HTML Images HTML Tables HTML Lists HTML Blocks HTML Layout HTML Forms HTML Iframes HTML Colors HTML Colornames HTML Colorvalues HTML JavaScript HTML Entities HTML URL Encode HTML Quick List HTML Summary HTML XHTML

## HTML5 News

HTML5 Intro HTML5 New Elements HTML5 Canvas HTML5 SVG HTML5 Drag/Drop HTML5 Geolocation HTML5 Video HTML5 Audio HTML5 Input Types HTML5 Form Elements HTML5 Form Attributes HTML5 Semantic HTML5 Web Storage HTML5 App Cache HTML5 Web Workers HTML5 SSE

## HTML Media

HTML Media HTML Object HTML Audio HTML Video HTML YouTube

## HTML Examples

HTML Examples HTML Quiz HTML5 Quiz HTML Certificate HTML5 Certificate

## HTML References

HTML Tag List HTML Attributes HTML Events HTML Canvas HTML Audio/Video HTML Doctypes HTML Colornames HTML Colorpicker HTML Colormixer HTML Character Sets HTML ASCII HTML ISO-8859-1 HTML Symbols HTML URL Encode HTML Lang Codes HTTP Messages HTTP Methods Keyboard Shortcuts

# HTML Videos

« Previous
Next Chapter »

Videos can be embedded in HTML pages with several methods.

## Playing Videos in HTML

## Example

<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
<source src="movie.webm" type="video/webm">
<object data="movie.mp4" width="320" height="240">
<embed src="movie.swf" width="320" height="240">
</object>
</video>
Try it yourself »

## Problems, Problems, and Solutions

Playing videos in HTML is not easy!

You must add a lot of tricks to make sure your video will play in all browsers (Internet Explorer, Chrome, Firefox, Safari, Opera) and on all hardware (PC, Mac , iPad, iPhone).

In this chapter W3Schools summarizes the problems and the solutions.

## HTML Video - Using <embed>

The <embed> tag defines a container for external (non-HTML) content.

The following HTML fragment displays a Flash video embedded in a web page:

## Example

<embed src="intro.swf" height="200" width="200">
Try it yourself »

Problems

- If the browser does not support Flash, the video will not play
- iPad and iPhone do not support Flash videos

## HTML Video - Using <object>

The <object> tag tag can also define a container for external (non-HTML) content.

The following HTML fragment displays a Flash video embedded in a web page:

## Example

<object data="intro.swf" height="200" width="200"></object>
Try it yourself »

Problems:

- If the browser does not support Flash, the video will not play
- iPad and iPhone do not support Flash videos

## The HTML5 <video> Element

The HTML5 <video> tag defines a video or movie.

The <video> element works in all modern browsers.

The following example uses the HTML5 <video> tag, which specifies one MP4 file (for Internet Explorer, Chrome, Firefox 21+, and Safari), and one OGG file (for older Firefox and Opera). If something fails, it will display a text:

## Example

<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
Try it yourself »

Problems:

- You must convert your videos to many different formats
- The <video> element does not work in older browsers

## HTML Video - The Best Solution

The best solution is to use the HTML5 <video> element + the <embed> element.

The example below uses the <video> element and tries to play the video either as MP4 or OGG. If that fails, the code "falls back" to try the <embed> element:

## HTML 5 + <object> + <embed>

<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
<object data="movie.mp4" width="320" height="240">
<embed src="movie.swf" width="320" height="240">
</object>
</video>
Try it yourself »

Problems:

- You must convert your videos to many different formats

## HTML Video - YouTube Solution

However, maybe the easiest way to display videos in HTML pages, is to use YouTube (see next chapter)!

## HTML Video - Using A Hyperlink

If a web page includes a hyperlink to a media file, most browsers will use a "helper application" to play the file.

The following code fragment displays a link to a Flash video. If a user clicks on the link, the browser will launch a helper application to play the file:

## Example

<a href="intro.swf">Play a video file</a>
Try it yourself »

## Tips About Inline Videos

When a video is included in a web page it is called inline video.

If you plan to use inline videos, be aware that many people find it annoying. Also note that some users might have turned off the inline video option in their browser.

Our best advice is to include inline videos only in pages where the user expects to see a video. An example of this is a page which opens after the user has clicked on a link to see the video.

## HTML Multimedia Tags

New : New tags in HTML5.

Tag | Description
--- | ---
<embed> | Defines an embedded object
<object> | Defines an embedded object
<param> | Defines a parameter for an object
<audio> New | Defines sound content
<video> New | Defines a video or movie
<source> New | Defines multiple media resources for media elements (<video> and <audio>)
<track> New | Defines text tracks for media elements (<video> and <audio>)

« Previous
Next Chapter »

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE