用于显示路径/目录的语义 HTML 标记?
是否有适合标记路径或目录的标签?
例如:
我已经检查了所有新的 HTML5 标记,但似乎没有一个适合此目的。那么哪一个会接近呢?
Is there any tag that's suited to markup a path or directory?
For example: <path>user/project/</path>
I've checked all new HTML5 tags but there doesn't seem to be one that fits this purpose. So which one would come close?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
https://www.w3.org/TR/ html51/textlevel-semantics.html#the-code-element
https://www.w3.org/TR/html51/textlevel-semantics.html#the-code-element
如果它是代码的一部分,您可以使用
code.path
。如果它是一些示例输出,您可以使用
samp.path
。如果您想列出这些部分,您可以使用 ol.path 并设置其显示方式的样式:
但如果它只是一个路径,您应该使用 span.path 包装它代码>.
If it's part of code, you could use a
code.path
.If it's some sample output you could use
samp.path
.If you'd like to list the parts, you could use
ol.path
and style the way it's displayed:But if it's just a path, you should wrap it with
span.path
.不幸的是,HTML 中没有任何相关内容。您可以尝试将其包装在 HTML5 中的
Unfortunately there isn't anything in HTML for that. You could try to wrap it in a
<pre>
tag or<code>
in HTML5. Otherwise you can use a<span>
tag and style it how you want it to look like.您对此有何看法:
一个优点是您可以轻松选择完整路径,而不会意外选择其他文本。另一方面,它不太语义化,因为它是一个表单元素。
What do you think about this:
One advantage is that you can easily select the complete path without selecting other text accidentally. On the other hand it's not quite semantic since it's a form element.