Search code examples
htmlwebpolymerweb-component

What's the right way to define the <content> tag?


When defining an insertion point for light DOM in WebComponents, is there any difference between these two syntaxes?

<template id="my-element">
    <content></content>
</template>

and

<template id="my-element">
    <content/>
</template>

What's the right or the best way to define the tag?

I tested both syntaxes in Firefox/Chrome and they behave identically (at least in a simple test).


Solution

  • Look at https://developer.mozilla.org/en-US/docs/Web/HTML/Element/content :

    Tag omission: None, both the starting and ending tag are mandatory.