Marking up file names

Which HTML element do you use to markup file names in a text?

I’ve always wrapped them with <code> tags (I like to display them monospaced anyway), but a file name actually isn’t a piece of code.

Suggestions? Here’s an example:

  1. <p>Go to <code>index.php</code>.</p>
  2. <p>Go to <span class=“filename”>index.php</span>.</p>

I don’t think you use any tags - normal text would be fine.

<body>
This is an example filename index.php
</body>

But if you always display them monospaced i would use a <span class=“filenames”></span> and style it that way.

There isn’t a specific one as such; unless it’s part of a set of instructions that has options or variables or is part of a code block in which case you could such things like; KBD, VAR or CODE.

I use <kbd> for stuff people are expected to type in general.
I use <tt> for representing text to be typed by a user (like into a program).

*edit but it seems <kbd> is better to use in all cases of people typing stuff in, not TT

I’ve never used <var> for some reason. I guess because its use didn’t seem wide enough for me.

I use <code> for actual code, but I have used it for filenames. I’ve also used it for representing terminal sessions (sometimes with <b> tags representing the difference between what the console returns (prompts, error messages) and <tt> for what the user is typing in).
*edit2 but again <kbd> would be better to use than <tt>

<i> and <b> tags are usually used for typography things like book titles and names, but one might be able to stretch the meaning over to things like introduced code. The closest I’ve found to a standard for computer filenames was monospace font, which some browsers style <code> to look like but I would style it in the CSS for certainty.

I would prefer an actual HTML tag than a styled span, though, especially because the filename should never have to worry about being confused with some non-name text in that instance, regardless of the presence of styles. For this reasons, most programming books have a style guide for filenames, code snippets, and attributes/variables.

In fact another idea is to have a little style guide or legend at the top of the page in question explaining what styles mean what— and then let each different kind of tag you use have a different style. Thing is, the HTML tags you can use meaningfully are limited.