WHAT'S NEW?
Loading...

How to insert video in webpage (HTML5)

In HTML5 <video> element is used to embed a video in a web page. To play video in a web page you should have latest version of web browser.
HTML5 Video Example



HTML5 Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<!DOCTYPE html> 
<html>
<head> 
 <title> </title> 
</head> 
<body> 
<h1> Inserting Video </h1> 
 <video width="720" height="480" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
</body> 
</html> 

We can include height and width attribute to set the height and width of the video. The control attribute adds video controls such as play, pause, and volume. We can place autoplay attribute instead of control attribute and it will play the video automatically when we visit the web page. The autoplay attribute does not work in mobile devices like iPad and iPhone.

HTML5 supports three video formats mp4, webm and ogg. Where mp4 format is supported by most of the browsers. Thats why it will be better to use mp4 video format. The <source> element allows us to specify alternative video file which the browser may choose from. The browser will use the first recognized format. 

0 comments:

Post a Comment