问题
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?
回答1:
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.
回答2:
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.
https://www.w3.org/TR/html51/textlevel-semantics.html#the-code-element
回答3:
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:
<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
.
回答4:
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.
来源:https://stackoverflow.com/questions/4868939/semantic-html-tag-for-displaying-a-path-directory