Set path based on specific directory in HTML? - 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

Related

How to link to html in a folder not directly connected

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

How can I set a custom style for viewing images?

How can I do that? Because I don't really know the word but I hope somebody knows this.
If you guys don't understand this then there is a link.
https://media1.tenor.com/images/0f097ed319d498c2bda3d87ba4f6ff10/tenor.gif?itemid=12846096
It's a gif but they set it into a cool style and I don't know how to set it like that.
The page most likely isn't actually a gif image, it could be some file structure like
> tenor.gif
>> index.html
where tenor.gif is actually a folder, with index.html inside it. Per W3C standard, folders automatically open up index.html if there is one directly inside it.
You could put whatever html code you want in index.html and styling.
You can check the contrast of the styles in the CSS documentation, they usually add you to the styles and filters, so they are fully configurable

Bootstrap CSS & JSP

hope you're doing fine.
I am currently stuck with my Web App project. This is the context: I would like to code a Web App using J2E. There's a free template that I liked and thus I decided to download it. When starting to use it I notice the CSS isn't applied.
Instead of having this, I have this:
However I do not see where the error is. The CSS & Bootstrap files should be visible in the JSP file and IntelliJ recognizes them. However I can't display these files (whether css or even pictures) that are referenced in "href".
Here's the project structure and code, maybe something's wrong there.
I'm used to HTML and to my understanding JSP isn't too different. Are the referencings different though?
Thanks in advance for any help you'll give,
Fares
YES.
Found the answer. Put resources in different folder than WEB-INF.
I believe that, your HTML file is inside the WEB-INF folder, for the to work either remove the WEB-INF path
<link href='style/stylesheet.css'>
or move your HTML one folder up.

How to automatically load a CSS file into HTML

I have a basic index.html file in a folder, as well as many, many other files. I want them all to use the same CSS file, without having to manually add to every file. I was wondering if you renamed the file index.css or something like that it would automatically load into every HTML file in the folder? Out of curiosity, is there also a Javascript method for this too?
Bad news my friend No. There is no magical tool that will import the CSS into all of your files. You have to do it yourself. Also it's really easy
Get the CSS file
Import the CSS File
See it's that easy. Was it so hard to do it?
You can't do that with simple HTML.
Do a PHP template instead, basically with:
head
header
nav menu
a content/container div/section
footer
Then, include your HTML/PHP page in your content.
For instance, use $_GET or $_POST to know which page to include.

Dreamweaver templates transforming coldfusion <cfinclude> paths from relative to absolute

I am pretty new to both Dreamweaver and Coldfusion, and I am having a terrible time figuring out this issue. I am sure the fix is very simple.
When I create a new page from an existing template in dreamweaver, any of my tags get their paths resolved by Dreamweaver from relative to absolute, with respect to my local copy of the site, not the remote site.
For instance,
In my template I have something like
<cfinclude template="../../stuff.cfm"\>
But when I create a new page from that template I get
<cfinclude template="file:///C|/Users/Me/Documents/MySite/stuff.cfm">
Which is obviously incorrect.
How can I change it so that when creating a page from a template in Dreamweaver, it doesn't do this.
I think it uses file:///C: until you save the new document.
Then it changes it to a relative location.
Use
<cfinclude template="#ExpandPath("../../stuff.cfm")#"/>
The "in code" answer is the right way to approach this, but for general path preferences, you can set that in Dreamweaver too:
Set the relative path of new links
Once the document is saved Dreamweaver will updated the links to Relative Paths to the document.