How to link to html in a folder not directly connected - html

I am creating a website with simple HTML+CSS. How do I create a hyperlink (href) in an HTML file, to an HTML file in a folder, that is not directly related.
See picture. If I want to insert a link in HTML 4 to HTML 3.
I know one can use ..\HTML2.html to go back in parent folder, but what is the best way here?

Typing / points to the relative root directory. So you can just do HTML 3 and it should take you to HTML3.
You can also use HTML 3 as you seem to know.
General recommendation would be to pick the closest path. If it's from the root, then select the first. If it's from a relative point from where you are, then the second.

Considering your drawing, I assume that node 1 is the root so the simplest way would be: .\html3.html

Related

Set path based on specific directory in HTML?

Let's say I am in
main/component1/index.html
and I want my html button to link me to main/component2/.
But the same index.html file is also used for the directory
main/component3/dir1/index.html
and I still want to link it to main/component2/.
Specifications:
I specifically know my main.
The root will be variable, I want to be able to package main/, then unpackage in another directory with working links.
If there is no HTML solution to this, then I'll try to write a solution in JS; I just wanted to know if it was possible in pure HTML.
How would I go about doing this? Thank you!
If I understood your question - no, you can't make it with HTML only, because HTML is not programing language, but markup language.
You can make relative and absoulte paths but not "variabled" paths.
Read more here:
https://stackoverflow.com/a/18321468/2719670

HTML - Link to files in a different folder

I am trying to make a clickable link to an HTML doc that is in a different folder than the original doc. I have read article after article and I can't figure it out.
Hello
I understand this fine^
Usually, when I'm linking to another file, it is in the same folder as the one I'm currently using so it works just fine.
Please see the path bellow I use on my computer to reach the file I want:
Desktop>My Folder>Oct 2020>Oct 15
After reading through articles on the subject, I came up with this, but it's not working.
<a href="file:///C:/Desktop/My Folder/Oct 2020/Oct 15/hello.html" target="_blank">
Obviously, there is a key concept I am missing here.
Your advice is appreciated!
What you want to do is determine how to get from the folder that contains your HTML document to the folder that contains your original document.
When writing a path from one folder to another, separate each folder with a /, and use two periods .. to go "up" one level in your folders.
For example, in the folders shown below, if you wanted to edit file1.html which is in My Folder so it contained a link to hello.html, you could use a link like this:
Hello
If, instead, you wanted to edit file2.html so it contained a link to hello.html, then you could use a link like this:
Hello
Note that we need to go "up" two levels (up to Nov 2020 and then up to My Folder), so we need to use .. twice.

can't load svg from filepath in json file

I'm trying to load SVG image from JSON file that contains a path like this -
<img src="../images/filename.svg"/>
and the image doesn't load.
When i try to do this it works-
<img src="/static/media/filename.9f72c13b.svg"/>
What is the difference? Why does the second work and the first doesn't ?
Is there a way to change all of the first paths to be like the second?
Thank you!
../ in a path means one level up from the current folder. So your first path is a relative path, and the second one is an absolute path. Besides, those are pointing to 2 different file-names (filename.svg and filename.9f72c13b.svg). First, you need to figure out to which file you want to refer, and then make sure it's present in that your specified location.
Is there a way to change all of the first paths to be like the second?
Yes, you can just use a simple text-replacing feature of your text-editor, say for example notepad++ which can do replace text with regular expressions and in multiple files simultaneously.
A note about the 'current directory': it's a bad idea to rely on assumptions about it, because on some platforms it may not be what you want, or it may even change from version to version.

Why does my link say unable to find file?

I am working on a project and am making an anchor tag link to another page (just another page on the website). Yet when I do this, it says, "Your file was not found". What could be wrong? Here is what my anchor tags look like
<a id="mission-link" class="link" href=".../Home/index.html#mission">
Thanks for the help and have a great day
You are using 3 dots instead of 2
.../Home/index.html#mission
should be
../Home/index.html#mission
If that still doesn't fix it, then we'd need to know your folder structure to know whether you should actually be moving up a directory or not. .. moves up a directory from where the current file is.

Where/how to save the star image(s) for this star-rating tutorial?

I'm a relative newcomer to HTML/CSS trying to implement this star-rating tutorial: http://www.dillerdesign.com/css/cookbook/component_star_rater.html
The text and hovers are functioning, but the star images are not showing up. From what I understand, I should only need to use the one image, called "img/star_rate.gif", is that correct? If so, where should I store the image? Do I need to create a new folder called "img" in my directory tree to store the image?
Thanks!
Yes maybe. The img/ part of the path is specifying a sub-directory. If you take that part out you don't need the directory.
Yes, create a folder called img and place your star_rate.gif inside that folder. That's what the / means.