自定义元素(htmlelement)允许作为列表的孩子(< ul> and&&< ol>)?
我认为这是不允许的:
<ul>
<my-li>
#shadow-root
<li>
<span>hello!</span>
</li>
</my-li>
</ul>
但是我们该怎么做才能不打破语义?我知道,htmlelement
以外的其他元素将存在,但是Safari并非如此。获得适当的HTML语义的最佳解决方案是什么?
I figure this is not allowed:
<ul>
<my-li>
#shadow-root
<li>
<span>hello!</span>
</li>
</my-li>
</ul>
But what can we do to not break semantics? I know that elements other than HTMLElement
would exist, but Safari is not okay with this being the case. What would be the best solution to achieve a proper HTML semantic?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您构造自定义元素时,您可以告诉它以这样的方式扩展现有元素:
要使用它,您仍然会使用常规,语义,语法上正确的列表项目元素,但是您告诉浏览器,它是一个实例带有
的自定义元素是
属性。Custom elements can customize existing elements. If you're wanting to create a custom list item element, you should probably extend the existing one. This will allow you to validly place it as a child of an unordered list element.
When you're constructing a custom element, you can tell it to extend an existing element like so:
To use it, you would still use a regular, semantic, syntactically correct list item element, but you tell the browser it's an instance of a custom element with the
is
attribute.如果您正在寻求验证HTML元素的语义使用,则可以执行在这里
If you are looking for validating on semantic use of HTML elements, then you can do that here