Reputation: 161
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
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
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