Falytom logoFALYTOM
Games
ToolsUI ComponentsServicesProductsAbout
LoginSign Up
menu
  1. Home
  2. /Web Development
  3. /Html
  4. /Video Elements
Your Progress0%
0 of 76 completed

Topics

Getting Started

  • What is HTML?
  • How the Web Works
  • Setting Up Your Environment
  • Your First HTML Page

HTML Document Structure

  • The DOCTYPE Declaration
  • The HTML Element
  • The Head Section
  • Meta Tags
  • The Body Element
  • HTML Comments

Text and Formatting

  • Headings (h1-h6)
  • Paragraphs
  • Line Breaks and Horizontal Rules
  • Text Formatting (Bold, Italic, etc.)
  • Quotations and Citations
  • Preformatted Text and Code
  • Subscript and Superscript

Links and Navigation

  • Creating Links
  • Absolute vs Relative URLs
  • Link Targets and Attributes
  • Email and Phone Links
  • Internal Page Links

Images and Media

  • Adding Images
  • Image Attributes
  • Image Formats
  • Figure and Figcaption
  • Responsive Images
  • Audio Elements
  • Video Elements
  • Embedding Content

Lists

  • Unordered Lists
  • Ordered Lists
  • Description Lists
  • Nested Lists

Tables

  • Table Basics
  • Table Headers and Footers
  • Spanning Columns and Rows
  • Table Captions
  • Styling Tables

Forms - Part 1 (Basics)

  • Introduction to Forms
  • Text Input Fields
  • Labels and Placeholders
  • Textarea Element
  • Checkboxes
  • Radio Buttons

Forms - Part 2 (Advanced)

  • Select Dropdowns
  • File Upload Inputs
  • HTML5 Input Types
  • Form Validation
  • Form Buttons
  • Fieldsets and Legends
  • Form Accessibility

Semantic HTML

  • What is Semantic HTML?
  • Header and Footer
  • Nav Element
  • Main and Article
  • Section and Aside
  • Div vs Semantic Elements
  • Time and Mark Elements

HTML5 Features

  • HTML5 Overview
  • Canvas Element
  • SVG in HTML
  • Geolocation API
  • Drag and Drop
  • Local Storage
  • Web Workers

Web Accessibility

  • Introduction to Accessibility
  • ARIA Attributes
  • Keyboard Navigation
  • Alt Text Best Practices
  • Color Contrast and Typography
  • Testing for Accessibility

Best Practices & SEO

  • HTML Best Practices
  • SEO Fundamentals
  • Meta Tags for SEO
  • Structured Data

Video Elements

Embedding video content in your web pages

The HTML5 video element makes it simple to embed video content directly into web pages without plugins. You can add tutorials, demonstrations, promotional content, or any video media with native HTML support.

The Video Element

The <video> element embeds video content in documents. Like the audio element, it can contain one or more video sources.

Basic Video

basic-video.html
<video src="tutorial.mp4" controls width="640" height="360">
  Your browser does not support the video element.
</video>

Video Attributes

controls

The controls attribute displays the browser's default video controls (play, pause, volume, progress, fullscreen):

with-controls.html
<video src="demo.mp4" controls width="800" height="450">
  Your browser does not support the video element.
</video>

width and height

Always specify width and height to prevent layout shift:

dimensions.html
<video src="video.mp4" controls width="1280" height="720">
  Your browser does not support the video element.
</video>

poster

The poster attribute specifies an image to display before the video plays:

poster.html
<video src="promo.mp4" 
       controls 
       width="1920" 
       height="1080"
       poster="thumbnail.jpg">
  Your browser does not support the video element.
</video>

autoplay

The autoplay attribute makes the video start automatically:

autoplay.html
<video src="intro.mp4" autoplay muted controls width="800" height="450">
  Your browser does not support the video element.
</video>

⚠️ Important About Autoplay:

Most browsers will only allow autoplay if the video is muted. Autoplay with sound is blocked to prevent annoying user experiences. Always include muted when using autoplay.

loop

The loop attribute makes the video repeat continuously:

loop.html
<video src="background.mp4" loop muted autoplay width="1920" height="1080">
  Your browser does not support the video element.
</video>

muted

The muted attribute starts the video with sound turned off:

muted.html
<video src="banner.mp4" muted autoplay loop width="1600" height="900">
  Your browser does not support the video element.
</video>

preload

The preload attribute suggests how the browser should load the video:

preload.html
<!-- Don't preload -->
<video src="video.mp4" preload="none" controls width="800" height="450"></video>

<!-- Preload metadata only -->
<video src="video.mp4" preload="metadata" controls width="800" height="450"></video>

<!-- Preload entire video -->
<video src="video.mp4" preload="auto" controls width="800" height="450"></video>

playsinline

The playsinline attribute prevents fullscreen playback on mobile devices:

playsinline.html
<video src="video.mp4" controls playsinline width="800" height="450">
  Your browser does not support the video element.
</video>

Video Formats

Different browsers support different video formats. The main formats for web video are:

FormatMIME TypeBrowser SupportQuality
MP4 (H.264)video/mp4All browsersGood, widely compatible
WebMvideo/webmMost modernExcellent, smaller files
OGGvideo/oggSome browsersGood, open-source

Recommendation: Use MP4 as your primary format for maximum compatibility. WebM can be added for better compression in supporting browsers.

Multiple Video Sources

Provide multiple formats to ensure compatibility:

multiple-sources.html
<video controls width="1280" height="720" poster="thumbnail.jpg">
  <source src="video.webm" type="video/webm">
  <source src="video.mp4" type="video/mp4">
  <source src="video.ogg" type="video/ogg">
  Your browser does not support the video element.
  <a href="video.mp4">Download the video</a>
</video>

The browser will try each source in order and use the first one it supports.

Practical Examples

Tutorial Video

tutorial.html
<article>
  <h2>How to Build a Website</h2>
  
  <figure>
    <video controls width="1280" height="720" poster="lesson-thumbnail.jpg">
      <source src="lesson-1.mp4" type="video/mp4">
      <source src="lesson-1.webm" type="video/webm">
      Your browser does not support the video element.
    </video>
    <figcaption>Lesson 1: Getting Started with HTML</figcaption>
  </figure>
  
  <p>In this lesson, you'll learn the basics of HTML...</p>
</article>

Product Demo

product-demo.html
<section class="product-demo">
  <h2>See Our Product in Action</h2>
  
  <video controls 
         width="1920" 
         height="1080" 
         poster="product-poster.jpg"
         preload="metadata">
    <source src="product-demo.mp4" type="video/mp4">
    <source src="product-demo.webm" type="video/webm">
    <p>
      Your browser doesn't support HTML video.
      <a href="product-demo.mp4">Download the video</a>
    </p>
  </video>
  
  <p>Watch how easy it is to use our software...</p>
</section>

Background Video

background-video.html
<header class="hero">
  <video autoplay 
         muted 
         loop 
         playsinline 
         width="1920" 
         height="1080"
         poster="hero-poster.jpg">
    <source src="hero-background.mp4" type="video/mp4">
    <source src="hero-background.webm" type="video/webm">
  </video>
  
  <div class="hero-content">
    <h1>Welcome to Our Site</h1>
    <p>Discover amazing products</p>
  </div>
</header>

Video Gallery

video-gallery.html
<section class="video-gallery">
  <h2>Video Portfolio</h2>
  
  <div class="video-grid">
    <figure>
      <video controls width="640" height="360" poster="project1-thumb.jpg">
        <source src="project1.mp4" type="video/mp4">
      </video>
      <figcaption>Project 1: Brand Campaign</figcaption>
    </figure>
    
    <figure>
      <video controls width="640" height="360" poster="project2-thumb.jpg">
        <source src="project2.mp4" type="video/mp4">
      </video>
      <figcaption>Project 2: Product Launch</figcaption>
    </figure>
    
    <figure>
      <video controls width="640" height="360" poster="project3-thumb.jpg">
        <source src="project3.mp4" type="video/mp4">
      </video>
      <figcaption>Project 3: Documentary</figcaption>
    </figure>
  </div>
</section>

Responsive Video

Make videos responsive with CSS:

responsive-video.css
/* Responsive video container */
.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
}

.video-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Simple responsive */
video {
  max-width: 100%;
  height: auto;
  display: block;
}
responsive-video-html.html
<div class="video-container">
  <video controls poster="thumbnail.jpg">
    <source src="video.mp4" type="video/mp4">
  </video>
</div>

Subtitles and Captions

Use the <track> element to add subtitles, captions, or descriptions:

subtitles.html
<video controls width="1280" height="720">
  <source src="video.mp4" type="video/mp4">
  
  <!-- English subtitles -->
  <track src="subtitles-en.vtt" 
         kind="subtitles" 
         srclang="en" 
         label="English">
  
  <!-- Spanish subtitles -->
  <track src="subtitles-es.vtt" 
         kind="subtitles" 
         srclang="es" 
         label="Español">
  
  <!-- Audio descriptions -->
  <track src="descriptions.vtt" 
         kind="descriptions" 
         srclang="en" 
         label="Audio Descriptions">
  
  Your browser does not support the video element.
</video>

VTT File Format

subtitles-en.vtt
WEBVTT

00:00:00.000 --> 00:00:03.000
Welcome to this tutorial.

00:00:03.500 --> 00:00:07.000
In this video, we'll learn about HTML.

00:00:07.500 --> 00:00:10.000
Let's get started!

Accessibility Considerations

♿ Accessibility Best Practices:

  • Always include controls for user control
  • Provide captions/subtitles for spoken content
  • Add audio descriptions for visual-only content
  • Include transcripts below the video
  • Ensure keyboard navigation works
  • Provide alternative text descriptions
  • Don't rely solely on video to convey information
  • Test with screen readers

Fully Accessible Video

accessible-video.html
<section aria-labelledby="video-title">
  <h2 id="video-title">Tutorial: Getting Started with HTML</h2>
  
  <figure>
    <video controls 
           width="1280" 
           height="720"
           poster="tutorial-poster.jpg">
      <source src="tutorial.mp4" type="video/mp4">
      <source src="tutorial.webm" type="video/webm">
      
      <track src="captions-en.vtt" 
             kind="captions" 
             srclang="en" 
             label="English" 
             default>
      <track src="descriptions.vtt" 
             kind="descriptions" 
             srclang="en" 
             label="Audio Descriptions">
      
      <p>
        Your browser doesn't support HTML video.
        <a href="tutorial.mp4">Download the video</a>
      </p>
    </video>
    <figcaption>A 10-minute introduction to HTML basics</figcaption>
  </figure>
  
  <details>
    <summary>View Full Transcript</summary>
    <div class="transcript">
      <p><strong>[00:00]</strong> Welcome to this tutorial...</p>
      <p><strong>[00:15]</strong> HTML stands for...</p>
    </div>
  </details>
</section>

Performance Optimization

💡 Video Performance Best Practices:

  • Compress videos before uploading
  • Use preload="metadata" or preload="none" for better initial page load
  • Always specify width and height
  • Provide appropriate poster images
  • Consider hosting videos on dedicated platforms (YouTube, Vimeo)
  • Use lazy loading for below-the-fold videos
  • Optimize poster images
  • Consider adaptive bitrate streaming for longer videos

Best Practices

✅ Do:

  • Always include controls attribute
  • Specify width and height to prevent layout shift
  • Provide poster images for better user experience
  • Include multiple formats for compatibility
  • Add captions/subtitles for accessibility
  • Compress videos to reduce file size
  • Use muted with autoplay if needed
  • Include fallback content and download links

❌ Don't:

  • Use autoplay with sound (blocked by browsers)
  • Upload uncompressed, huge video files
  • Forget to add controls
  • Rely only on one video format
  • Omit captions for spoken content
  • Forget width and height attributes
  • Use videos as the only way to convey important information

Video Hosting Considerations

Self-Hosting

Pros: Full control, no external dependencies, no ads

Cons: Bandwidth costs, storage costs, no adaptive streaming

Third-Party Platforms (YouTube, Vimeo)

Pros: Free hosting, adaptive streaming, analytics, CDN delivery

Cons: Less control, potential ads, privacy concerns

Key Takeaways

  • The <video> element embeds video content
  • Always include controls, width, and height
  • Use poster to show a thumbnail before playback
  • MP4 is the most widely supported video format
  • Provide multiple formats using <source> elements
  • Only use autoplay with muted attribute
  • Add captions/subtitles with <track> elements
  • Optimize video files and consider hosting options

What's Next?

Now that you understand video elements, you're ready to learn about embedding external content. In the next lesson, we'll explore the iframe and embed elements for including content from other websites, like YouTube videos, Google Maps, and more.

Know someone who'd find this guide helpful? Please share!

Previous
Audio Elements
Next
Embedding Content

Never Miss a New HTML Tutorial

Join 1,000+ developers learning HTML step-by-step. Get new tutorials, tips, and exclusive resources delivered to your inbox - completely FREE.

You might also like

UI Components

Ready-made components for your projects

Developer Tools

Boost productivity with handy generators

HTML Game

Learn HTML concepts through interactive gameplay

Join Our Web Development Training Program

Master frontend & backend development with hands-on projects.

Menu

Topics

Getting Started

  • What is HTML?
  • How the Web Works
  • Setting Up Your Environment
  • Your First HTML Page

HTML Document Structure

  • The DOCTYPE Declaration
  • The HTML Element
  • The Head Section
  • Meta Tags
  • The Body Element
  • HTML Comments

Text and Formatting

  • Headings (h1-h6)
  • Paragraphs
  • Line Breaks and Horizontal Rules
  • Text Formatting (Bold, Italic, etc.)
  • Quotations and Citations
  • Preformatted Text and Code
  • Subscript and Superscript

Links and Navigation

  • Creating Links
  • Absolute vs Relative URLs
  • Link Targets and Attributes
  • Email and Phone Links
  • Internal Page Links

Images and Media

  • Adding Images
  • Image Attributes
  • Image Formats
  • Figure and Figcaption
  • Responsive Images
  • Audio Elements
  • Video Elements
  • Embedding Content

Lists

  • Unordered Lists
  • Ordered Lists
  • Description Lists
  • Nested Lists

Tables

  • Table Basics
  • Table Headers and Footers
  • Spanning Columns and Rows
  • Table Captions
  • Styling Tables

Forms - Part 1 (Basics)

  • Introduction to Forms
  • Text Input Fields
  • Labels and Placeholders
  • Textarea Element
  • Checkboxes
  • Radio Buttons

Forms - Part 2 (Advanced)

  • Select Dropdowns
  • File Upload Inputs
  • HTML5 Input Types
  • Form Validation
  • Form Buttons
  • Fieldsets and Legends
  • Form Accessibility

Semantic HTML

  • What is Semantic HTML?
  • Header and Footer
  • Nav Element
  • Main and Article
  • Section and Aside
  • Div vs Semantic Elements
  • Time and Mark Elements

HTML5 Features

  • HTML5 Overview
  • Canvas Element
  • SVG in HTML
  • Geolocation API
  • Drag and Drop
  • Local Storage
  • Web Workers

Web Accessibility

  • Introduction to Accessibility
  • ARIA Attributes
  • Keyboard Navigation
  • Alt Text Best Practices
  • Color Contrast and Typography
  • Testing for Accessibility

Best Practices & SEO

  • HTML Best Practices
  • SEO Fundamentals
  • Meta Tags for SEO
  • Structured Data
Falytom logoFALYTOM

Learn technologies like HTML, CSS, JavaScript, React, NodeJS and more through interactive games, tutorials, components and free tools. Transform your businesses with AI chatbots, SEO-optimized websites, and professional development services.

© 2025 Tomilola Group
  • Facebook logo
  • Twitter logo
  • Instagram logo
  • LinkedIn logo
  • GitHub logo
  • YouTube logo