Format Code Now
/
Web & markupHTML Video Generator Next: HTML to PHP Converter ›

HTML Video Tag Generator

WM-67

List your video files and options and get a video element with source types, a poster image, a captions track and fallback content.

Runs in your browser. Nothing is uploaded.

Attribute lines: src: (repeat), poster:, width:, height:, track:, title:, fallback:

HTML

How to use it

  1. Add one or more src: lines. Several files become source elements in order.
  2. Add poster:, width:, height: and title: lines, and track: file, language, label, kind lines for captions.
  3. Tick controls, loop, muted or the other options, and pick the preload hint.
  4. Copy the HTML into your page.

Sources, types and fallback

With one file the address goes on the video element. With several, each becomes a source element and the browser plays the first one it can handle, so list your preferred format first. The tool fills in the type attribute from the extension for mp4, m4v, webm, ogv, ogg and mov, and leaves it out otherwise, which makes the browser work it out. Text inside the video element is fallback content for browsers without video support. Without your own fallback line the tool writes a sentence with a download link.

Captions with the track element

A track line has the form file, language, label, kind, for example captions.vtt, en, English, captions. The file must be WebVTT. The kind defaults to captions, and the other kinds are subtitles, descriptions, chapters and metadata; subtitles need a language code. Captions help anyone who cannot hear the audio and are a requirement of the WCAG standard at level A for prerecorded video that has sound. The tool only writes the element: it does not create or check the caption file.

Autoplay, muted and size

Many browsers only allow autoplay when the video is muted, and the tool does not add muted for you, so tick both options. Playsinline asks iPhones to play in the page instead of full screen. The poster image shows before playback, and width and height let the browser reserve space so the page does not jump. Preload is a hint about how much to fetch up front, not an instruction. Addresses beginning with javascript: are refused, and all values are escaped.

Error messages and what to do

MessageWhat it meansFix
Add at least one "src: video-url" line (add more for other formats).There is no src: line.Add src: and the video file address.
A track line needs a file, for example "track: captions.vtt, en, English".A track: line has no file.Put the file first, then the language and label.

Questions people ask

How do I add a video to a web page in HTML?

Use the video element with a src, or with source children for several formats, and add controls so people can play it. This tool builds that from your file list.

How do I add captions to an HTML video?

Add a track element with kind="captions", a WebVTT file in src, a srclang and a label. Use a track: line in this tool. The caption file must be in WebVTT format, and the browser shows a captions button when a track is present.

Why does my video not autoplay?

Many browsers block autoplay with sound. Add both autoplay and muted, and playsinline for iPhones. Autoplay is not guaranteed in every browser. If it still does not play, check that the page was interacted with, and give users the controls to start it manually.

Which video formats should I list?

List MP4 for the widest support and WebM as an alternative. The browser plays the first source it supports, so order them by preference. Source order matters, so put the format you want first. Keep a link as fallback for older browsers and for people who prefer to download.

What does the poster attribute do?

It sets an image shown before the video plays. It also works as a placeholder while the video loads. Without a poster, browsers show the first frame once it loads, or a blank box until then, depending on the preload setting.

About this tool

Builds a video element from the files you list. One src line goes on the video element itself; several lines become source elements in the order given, and the browser plays the first one it supports. The type attribute is filled in from the extension for mp4, m4v, webm, ogv, ogg and mov, and left out for other extensions. A track line is "file, language, label, kind" and writes a track element; the kind defaults to captions and the file must be WebVTT. Without a fallback line, a short message with a download link is written. Autoplay is not changed for you: many browsers only allow autoplay when the video is muted. Videos are not loaded here.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.