Search code examples
amp-html

Why is closed tag needed for amp-img?


The <amp-img ...> need a </amp-img>.
Why?
My first idea was to put a simple <img .. /> in as fallback for non js-browser. But this is not valid for AMP.
And my second question is will AMP handle (or reserved for future) like text or something else between the amp-img or other tags like amp-ad etc. that's don't need a closing tag to works fine?


Solution

  • The close tag is needed, because close-tags are needed for all tags in HTML except for a very small whitelist. img as you mention and a few others. All "custom elements" (sometimes also called web components) need closing tags since they are not on the short whitelist.