Matroska is a tree of variable-length elements called EBML. WebM is a subset of it.
MKV (Matroska) and WebM come from a different lineage than MP4. Their foundation is EBML (Extensible Binary Meta Language), a tree in which elements contain elements, like XML, but written in binary. It is an open format with a public specification, and the element definitions can be checked in the Matroska specification and in the documents standardized by the IETF (RFC 8794 for EBML, RFC 9559 for Matroska).
An EBML element is ID + size + data. Its distinguishing feature is that both the ID and the size are written as variable-length integers. The number of leading zeros in the first byte tells you how many bytes the value takes. This contrasts with MP4 boxes, which use a fixed 4-byte size. Like MP4, even an ID you don't recognize can be skipped because you can read its size.
matroska or webm.In MKV, both the data (Cluster) and the index (Cues) are elements inside the Segment, so it is easy to keep appending from the front before the file is finished. Even if a recording is cut off partway, the clusters already written can generally still be read, which is why recording software (such as OBS with its MKV recording) recommends MKV. For live use, writing the Segment size as "unknown" is also a technique that is used.
WebM is a profile restricted for the web, built on the Matroska structure. Its DocType is webm, and it limits video to royalty-free codecs such as VP8, VP9, and AV1, and audio to Vorbis and Opus (VP9 and AV1). So "every WebM can be read as MKV, but not every MKV is WebM." Conversely, if you put H.264+AAC in an MKV, that file is not WebM.
Compatibility depends on the environment. Check whether a file will actually play with the codec support tool.
An element-tree format that writes IDs and sizes with variable lengths. The basis of Matroska and WebM.
In Matroska, a unit that groups a span of time's worth of blocks. It has its own reference timestamp.
The element in Matroska that serves as the seek index.
A value written in the EBML header. It distinguishes matroska from webm.
Which statement correctly describes the relationship between WebM and MKV?