Relative Links - Windows vs. Linux

Windows and Linux use different syntax for their file structures. Windows uses a backward slash \ to designate child directories and Linux uses a forward slash / for child directories. It seems to me that the relative file path, in an anchor element for example, will similarly have a different format, depending upon whether the file is hosted in a Linux or Windows environment.

An example might be:
Windows: .\resources\css\index.css
Linux: ./resources/css/index.css

My question - does the browser automatically process either format? or does the developer need to adapt the code depending on the host OS?

Thank you.

The backslash in paths is very much confined to Windows, but you can safely write relative paths in web documents using / and you ought to have no issues.

You’d likely only need to accommodate a backslash if you were hard-linking based on an explicit file path, e.g. C:\some_dir\my_resource.png, but that in itself is not really something you’d expect to see in production. :slight_smile: