简体   繁体   English

用于显示路径/目录的语义HTML标记?

[英]Semantic HTML tag for displaying a path/directory?

Is there any tag that's suited to markup a path or directory? 是否有适合标记路径或目录的标记?

For example: <path>user/project/</path> 例如: <path>user/project/</path>

I've checked all new HTML5 tags but there doesn't seem to be one that fits this purpose. 我已经检查了所有新的HTML5标签,但似乎没有适合此目的的标签。 So which one would come close? 那么哪一个会接近?

The code element represents a fragment of computer code. 代码元素表示计算机代码的片段。 This could be an XML element name, a filename , a computer program, or any other string that a computer would recognize. 这可以是XML元素名称, 文件名 ,计算机程序或计算机可识别的任何其他字符串。

https://www.w3.org/TR/html51/textlevel-semantics.html#the-code-element https://www.w3.org/TR/html51/textlevel-semantics.html#the-code-element

If it's part of code, you could use a code.path . 如果它是代码的一部分,您可以使用code.path

If it's some sample output you could use samp.path . 如果它是一些示例输出,您可以使用samp.path

If you'd like to list the parts, you could use ol.path and style the way it's displayed: 如果您想列出部件,可以使用ol.path并按照显示方式设置样式:

<ol class="path">
  <li class="dir">user</li>
  <li class="dir">project</li>
<ol>

But if it's just a path, you should wrap it with span.path . 但如果它只是一个路径,你应该用span.path包装它。

Unfortunately there isn't anything in HTML for that. 不幸的是,HTML中没有任何内容。 You could try to wrap it in a <pre> tag or <code> in HTML5. 您可以尝试将其包装在HTML5中的<pre>标记或<code>中。 Otherwise you can use a <span> tag and style it how you want it to look like. 否则,您可以使用<span>标记并根据需要设置样式。

What do you think about this: 你怎么看待这件事:

<input type="text" value="user/project/" readonly="readonly" />

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. 另一方面,它不是语义,因为它是一个表单元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM