Welcome file javascript import - css

Currently, I have a jsp file that I am redirecting to from index.jsp to jsp/home.jsp
The import is something like this.
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.css">
the location of the above file is
webcontent/bootstrap/css/bootstrap.css
However, if I try to click on a link to jsp/signIn.jsp, I get file not found on the css file.
I am not sure why home.jsp is behaving like it is in webcontent folder when it is in webcontent/jsp
Is there a way to work around the issue?

Try this (with JSTL tag):
<link rel="stylesheet" type="text/css" href="<c:url value="/bootstrap/css/bootstrap.css"/>">

Got around the problem. Had to use the context path as supposed to using the relative path.
I didnt need to deal with having the behaviour of the file at all.
Guess thats the answer.
Use Context Path!!

Related

Style suddenly does not show after no changes made to it, no error in the console or cmd

I am working with node.js, express and .ejs files. My style did work and i did not change anything about it before it stopped.
Here is the code:
https://github.com/RTweety/todoapp-v1/tree/main/todoapp-v1
I've checked the path and changed both it in the script.js and list.ejs but no response.
I also tried to restore the code to the point when it did work but it did not work.
I've cloned Your Project and You have bug in header.ejs file.
Instead of this line
<link type="text/css" href="css/styles.css" />
You should use <link/> tag like that and that's it ! :-)
<link rel="stylesheet" href="css/styles.css" />
Here You have reference about How To link an external stylesheet
Folder and file structure script.js, header.ejs, terminal:
Output in browser:

How to add a working link to external css file in .NET core 5 project

My project is here
(Look for "Laptop" branch, and "IsolatorUI" internal project)
I need to work with external css file I just saved in wwwroot/css.
I have a schtml Home view file and I would like to use it there.
So far, everything I tried did not work. Even using the site.css which was already there was unsuccessful.
Please ignore the different languague on cshtml HomeView file.
How can I establish a css file link? There are many discussions and suggestions I found on the internet, but none of them worked for me.
It's really frustrating when such simple thing doesn`t work...
Basically there is a disturbing bug with css in .NET framework files, but eventually this code worked for me:
In my View:
#section Styles {
<link href="#Url.Content("~/css/Home.css")" rel="stylesheet" type="text/css" />
}
And in my Layout:
<head>
...
<link rel="stylesheet" type="text/css" href="~/css/site.css" />
#RenderSection("Styles", false)
</head>

CSS directory issues

can somebody help me with this directory issues. I have index.php page and have included header and footer.php header contains the <link href="new.css"/>, the new.css is located in the main directory. and everytime I try to separate the new.css from the main directory like css/new.css it is not working well on other elements but if I try to put it back to the main directory it works fine . can someone tell me why is that happening?
Example:
You have a file: http://mysite.com/blabla/blabla2/index.php
Now if you use: <link href="new.css"/> - it's same like <link href="http://mysite.com/blabla/blabla2/new.css"/>
So you need use this: <link href="css/new.css"/>
try to use <link href="../css/new.css" /> this might work.

Including CSS in MasterPages

I am new to the domain. I want to include a CSS file in my master pages,but it is not working can anyone try to help me out of this problem..
I give the link to the CSS externally as
<link href="Stylesheet1.css" rel="Stylesheet1" type="text/css" />
Is there any necessity to include CSS classes in master page if so how and where I have to include?
Try:
<link href="~/Stylesheet1.css" rel="Stylesheet1" type="text/css" />
Tilde (~) represent root directory.
If this doesn't work, if you can show us your directory structure, and look at the rendered source we can help more.
You can of course not use the Tilde (~) on tags that are not run server-side, what you have to do is something like this:
<link href="<%= ResolveClientUrl("~/Stylesheet1.css")%>" rel="stylesheet" type="text/css" />
Or just do a method that gives you back a full link-tag.
There's nothing wrong with the syntax of your <link> tag. The problem is likely to be caused by the fact that your CSS file isn't located at the URL you're attempting to get it from.
The href attribute in your markup specifies a file called Stylesheet1.css in the same folder as your master page. If its not you should specify the location of the stylesheet using standard, virtual path or move the stylesheet to the same folder as your masterpage.
More info.
http://w3schools.com/css/css_howto.asp

Why the CSS style is not applied in webpages within subdirectories?

In the root of my domain i have the CSS file style.css and the masterpage file site.master.
The link to the CSS file within the site.master is
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
The problem is that webpages contained within subdirectories do not inherit the CSS file.
What am i doing wrong here?
If i copy the style.css file to the subdirectories everything works like a charm...
UPDATE: If i change the path to /style.css or to ~/style.css the style is Not applied also to the webpages within the root folder.
MasterPages use the containing page for the path.
change your css tag to be a server control and use the "~" root symbol.
<link id="lnkStyle" runat="server" href="~/style.css"
rel="stylesheet" type="text/css" />
You need to specify the path as /style.css.
Well the obvious question is, does the other pages inherit the correct masterpage, namely the one with your css link?
ie.
<%# Page Language="C#" MasterPageFile="~/MasterPage.master"...
also perhaps '/' before file name would help
If you're including that link tag in your master page, the HTML being output by the content pages in subdirectories contains a link to "style.css", which the browser looks for in that directory.
If you're developing in ASP.NET, you should be placing your CSS files in themes, which will take care of this problem. If you really don't want to do that for some reason, make the URL to the stylesheet an application-relative path ("~/style.css") and make the link tag executed on the server; I believe that that will resolve the application path and generate an absolute URL.
Try this:
<link href="<%: Url.Content("~/style.css") %> rel="stylesheet" type="text/css" media="screen" />
It will make the path relative to your hostname, giving the correct path to your pages in the subdirectories. Right now, just linking style.css gives it the folder relative path, so its looking inside of the same folder your page is in, instead of where you intended. Hope that helps. You could also re-write your link with a preceding forward slash, like "/style.css" and that should also do the trick.

Resources