Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a proper way to create an html src path?

I know that the proper way to handle file/directory paths is to use Path.AltDirectorySeparatorChar, but does this apply to html source paths?

Or, is it that the backslash is the required path separator for html? I've always done it using the backslash (i.e. <img src="images\birthdaysurprise.jpg" />), but now I'm wondering if I've been doing it improperly this entire time?

like image 736
myermian Avatar asked Sep 05 '25 17:09

myermian


1 Answers

While I don't know the exact letter of the law, use the forward slash for all path separators. Even Windows can use a forward slash as a separator in its APIs.

Using a backslash may work under a windows platform but:

  • It looks weird
  • Will die and gag if you move to a *nix based system.
  • May end up breaking some code that assume the forward slash
  • \ starts an escape sequence in many instances, so \n could translate in an unexpected way.
like image 191
Jeremy J Starcher Avatar answered Sep 07 '25 09:09

Jeremy J Starcher