HTML 类中的管道字符
我在 W3C 文档中找不到任何禁止使用管道字符 | 的内容,例如:
<div class="class1|class2">
不要担心我可能会用它做什么。我只是想知道这是否“合法”。
I couldn't find anything in the W3C docs that said pipe chars, |, aren't allowed, for instance:
<div class="class1|class2">
Don't worry about what I might be using it for. I was just wondering if it's "legal".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
相关规则可以在w3c syndata tokenization部分中找到,尽管它是很难从那里得出管道是否有效的结论,乍一看,似乎任何东西对于选择器都是有效的,即:
The relevant rules can be found in w3c syndata tokenization section, though it's pretty difficult to conclude from there if pipe is valid or not, as per a glance, it seems that anything is valid for a selector, i.e.:
它是合法的 HTML,因为类的数据类型是 CDATA。 CSS 选择器会出现问题,因为管道不是选择器的有效字符。
It's legal HTML, since the datatype of class is CDATA. You will have a problem with CSS selectors, because the pipe is not a valid character for a selector.
它是类名中的有效字符。事实上,我看到一个网站使用管道(|)只是为了类分离。我认为这是提高可读性的一个很好的做法。
It is a valid character in a class name. In fact, I see a website using pipe ( | ) just for the sake of class separation. Which I think is a good practice for readability.