Is there any defined behaviour if I have an HTML5 VIDEO tag but include neither a SRC attribute nor SOURCE tags inside the element? Would this still be valid HTML, and if so, what should the (HTML5 capable) browser do – ignore the element or display it’s contents?
Share
Yes, there is defined behavior; HTML5 is trying to provide defined behavior for any case in which it could make a difference between browsers, to reduce incompatibility, even when dealing with invalid documents.
From my reading of the spec, it looks like it is invalid to have no
srcattribute orsourceelement:This seems to indicate to me that it must have either a
srcattribute or asourcechild element. But both the Validator.nu and the W3C Validator seem to think this is a valid document:Regardless of whether it’s valid, the behavior is defined in the resource selection algorithm as follows:
This implies a ready state of
HAVE_NOTHINGIn that state, the video is represented by its poster frame, or nothing:
When it’s represented by nothing, that means it appears as just a generic box; like a
div, that can be styled but has no intrinsic display of its own, though it will be the width and height specified by itswidthandheightattributes. For example:Note that it does not display its content, in browsers that support the
videotag. Content within thevideotag, other than thesourceelements, is intended to be fallback content displayed only by older browsers that don’t support thevideoelement: