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/<开发者_JS百科;/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?
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
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
.
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:
<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.
精彩评论