Self-closing vs. non self-closing tags


#1

I’m just musing about the nature of HTML here, no assistance is being sought with an exercise.

Why is the img tag self-closing but the video tag is not? Is there any logic to what is self-closing and what isn’t?

Why can’t all HTML5 elements be self-closing (so-called ‘void elements’)? What is the purpose of the closing tag anyway? It’s simply a placeholder to show the hierarchy of nested elements, no? However if the code is properly indented we don’t need it.


#2

An image element has no content, only attributes, src, alt, title, width, height, etc.

A video element may have content, such as a text message if the video does not render:

Your device does not support video.

This will take more reading to confirm, especially whether or not a placeholder image can be used in place of the video applet if it does not render, or until it is activated to render.

https://dev.w3.org/html5/spec-author-view/video.html#video


#3

It appears that a placeholder image is an attribute of the video element. From the page you referenced.

"The poster attribute gives the address of an image file that the user agent can show while no video data is available. The attribute, if present, must contain a valid non-empty URL potentially surrounded by spaces.

The image given by the poster attribute, the poster frame, is intended to be a representative frame of the video (typically one of the first non-blank frames) that gives the user an idea of what the video is like."


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.