Skip to main content

Search 436 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, guides, blog and product.

XML format

TTML captions

Timed text for subtitles and captions, carrying styling and positioning that SRT cannot — and the profile that broadcasters require.

TTML is the XML format behind broadcast and streaming captions, and the reason to reach for it over SRT is everything SRT cannot say: positioning, colour, region, alignment and the styling rules that make a caption legible over a bright shot. Its structure is deliberately CSS-like — styles are declared in <head> and referenced by id, not repeated inline.

The catch is that TTML is a family of profiles rather than one format. IMSC is what streaming platforms require, EBU-TT-D is what European broadcasters require, and SMPTE-TT is another. A document valid against the base TTML schema can be rejected by all three, because each profile constrains it further.

Constraints that bite

  • Times are expressed in whichever form the document declares — clock time, offset, or frames — and reading them without checking ttp:timeBase and ttp:frameRate gives the wrong answer.
  • Profiles matter more than the base schema. IMSC, EBU-TT-D and SMPTE-TT each narrow TTML, and platforms validate against the profile.
  • Regions and styles are referenced by id from <head>; an unresolved reference renders without styling rather than failing.
  • xml:lang on the root is required in most profiles and is how a player labels the caption track.
  • A caption that overlaps another in the same region is legal XML and a rendering defect; overlap has to be checked separately.
Root element
<tt>
Media type
application/ttml+xml
Extensions
.ttml, .dfxp, .xml
Namespaces
  • http://www.w3.org/ns/ttml
XMLDir label

Specification: W3C TTML2

A minimal valid document

Every example on this site is checked against the same parser the workspace uses, so what you see below is known to be well-formed.

ttml.xml
<?xml version="1.0" encoding="UTF-8"?>
<tt xmlns="http://www.w3.org/ns/ttml"
    xmlns:tts="http://www.w3.org/ns/ttml#styling"
    xml:lang="en">
  <head>
    <styling>
      <style xml:id="base" tts:color="white" tts:backgroundColor="black"
             tts:fontSize="80%" tts:textAlign="center"/>
    </styling>
    <layout>
      <region xml:id="bottom" tts:origin="10% 80%" tts:extent="80% 15%"/>
    </layout>
  </head>
  <body region="bottom">
    <div>
      <p begin="00:00:01.000" end="00:00:04.000" style="base">The engine weaves algebraic patterns.</p>
      <p begin="00:00:04.500" end="00:00:07.000" style="base">As the loom weaves flowers.</p>
    </div>
  </body>
</tt>

Get started

Bring order to the XML your team can't afford to ignore.

Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.