Skip to content Skip to sidebar Skip to footer

Semantic HTML Tag For Displaying A Path/directory?

Is there any tag that's suited to markup a path or directory? For example: user/project/ I've checked all new HTML5 tags but there doesn't seem to be one t

Solution 1:

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


Solution 2:

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.


Solution 3:

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.


Solution 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.


Post a Comment for "Semantic HTML Tag For Displaying A Path/directory?"