I have a project with such structure. CSS file is included like this
<link rel="stylesheet" type="text/css" href="../static/css/style.css"/>
When I open html file on it's own from my computer, css loads. But when i load it from GET request on localhost, css file is not found.
It is indeed a path mistake.
When you are using two dots before slash sign - browser searches for the file in two folders upper from the current place of index.html
The solution depends on where your index file is located, I think that when you put all the thing to localhost your index.html is in the root folder, so there is no need in dots before the slash sign, simply make your path like this:
<link rel="stylesheet" type="text/css" href="/static/css/style.css"/>
Or without "/static/", if you have also moved "css" folder to the root
If you are still calling index from the templates folder - try using this code
<link rel="stylesheet" type="text/css" href="./static/css/style.css"/>
Your path is incorrect. From the image the correct path seems to be
<link rel="stylesheet" type="text/css" href="../static.css/style.css"/>
Related
I m trying to create a sidebar where I have a style.css for customize it. When I inspect my page, it seems it never loads and get 404 not found.
<head>
<h1>sidebar</h1>
<title>Responsive Sidebar Menu</title>
<link rel="stylesheet" type="text/css" href="style.css"></head>
My project is structured like in the following picture:
I can't figure out how to write the path so it can load properly.
Move your template folder right under resources:
src/main/resource/static/css (for CSS files);
src/main/resource/templates (for HTML templates).
Then correct the link tag as follows:
<link href="../static/css/style.css" th:href="#{/css/style.css}" rel="stylesheet" />
I'm having a problem trying to access my static CSS resources from lower directories. If I am in the main directory it detects everything but if I go to other lower directories, it adds the path from that folder and does not detect them.
Error
(In that path "server" is a directory that should not appear, since css is in the main directory)
<link rel="stylesheet" href="/css/bootstrap.min.css">
<!-- Bootstrap CSS
============================================ -->
<link rel="stylesheet" href="/css/font-awesome.min.css">
I tried from putting ../, ./ searching the internet but I didn't find anything.
I am using Apache FreeMarker
Use .. to indicate the parent directory:
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" href="../css/font-awesome.min.css">
This will help you.
I am writing a very simple web application project by "IntelliJ IDEA" and "Tomcat". I downloaded and HTML file and pasted it into my index.jsp, this HTML also has a css file, but I do not know where to put it.
you can put css anywhere in project . All you need to select correct path in href .
<head>
<link rel="stylesheet" type="text/css" href="path_to_css/xyz.css">
</head>
you can put css and html in same directory. then use
<head>
<link rel="stylesheet" type="text/css" href="xyz.css">
</head>
I want to keep all CSS files in one folder and I want to access them. Below is the path of my CSS folder
css/sampl.css. Where css is the folder.
This is my code:
<link href="/CSS/sampl.css" rel="stylesheet" type="text/css" />
I can't access the sampl.css file. Could somebody help me out?
You are missing a context path in the URL. To prepend a context path you can use JSP EL
<link href="${pageContext.request.contextPath}/CSS/sampl.css" rel="stylesheet" type="text/css" />
The CSS folder is in the web application root.
My struts2 project structure as follows
Webcontent
css
abc.css
jsp
login.jsp
META-INF
WEB-INF
indeed to include the functions of abc.css in login page.How can i do that ? How can i give the path of css file in jsp page ?
Include your css with the following statement.
<head>
<link rel="stylesheet" type="text/css" href="../css/abc.css">
</head>
"../css/abc.css" is a relative path.
"../" represents one directory up. i.e., Login.jsp is in "jsp" directory "../" will make the directory as "Webcontent"
"../css" will traverse you upto "css" directory in the "Webcontent".
"../css/abc.css" will give the abc.css file.
you can include your css file like this.
<head>
<link rel="stylesheet" type="text/css" href="/Webcontent/css/abc.css">
</head>