Biebk
Biebk

Reputation: 161

What should we use forward slash / or backslash \ in absolute path of links?

All of these absolute path of links are working perfectly.

<img src="\Users\dell\Desktop\brackets html files\Images\animal640.png" alt="">
<img src="/Users/dell/Desktop/brackets html files/Images/animal640.png" alt="">
<img src="\Users/dell\Desktop/brackets html files\Images\animal640.png" alt="">

But which one am I supposed to use? Which one is the recommended one? What is the difference between them?

Upvotes: 4

Views: 5662

Answers (2)

ajpenano
ajpenano

Reputation: 11

I am currently taking the Web Dev bootcamp of Dr. Angela Yu. She uses forward slashes for local files (and of course website links) but I instead opted to use backward slash for local files and both work. I'm trying to be meticulous as to differentiate local files and URLs and so far I have not encountered any problem yet.

Edit: I found another answer (https://www.htmlvalidator.com/CSS-HTML-Forum/viewtopic.php?t=2684#:~:text=Paths%20in%20HTML%20(like%20those,use%20the%20forward%20slash%20character.) saying that the browser converts a forward slash to a backslash should it need to access a local file. I guess it's better to follow Dr. Yu's formatting instead of eventually getting a problem in the future where I had to change all of the backslash into forward slashes.

Upvotes: 0

Quentin
Quentin

Reputation: 944545

URLs use forward slashes (/) (on all platforms).

Backslashes (\) are used for local file paths on Windows. URLs are not local file paths. Not even file: scheme URLs are local file paths — they are URLs.

Upvotes: 5

Related Questions