Under to access css file in another folder - html

I have 2 folders, 1 named template where my index.html is. The other is named static where my main.css file is. I used the following code to access my css file from index.html but i got a 404 error. I'm using google app engine in python.
<link rel="stylesheet" href="../static/main.css" type="text/css">

If these folders are at the application root you could try using a url like below.
<link rel="stylesheet" href="/static/main.css" type="text/css">

try giving full path e.g
C:\xampp\htdocs\yourFolder\static\main.css

Related

Can't link local stylesheet on server?

I'm working on an HTML-based game using Node.js and I'm now working on the front end interface of it. I'm trying to link a CSS stylesheet, but I am getting a strange issue.
My folder structure is set up as follows:
C:\Users\myname\Documents\gamename, and within the gamename folder is the app.js file, and within client I have the index.html file to serve to the client. Within the client folder I also have the stylesheet, w3.css
Within the app.js I have the following line:
app.use('/client',express.static(__dirname + '/client'));
Inside index.html I have the following line:
<link rel="stylesheet" href='w3.css'>
However, when I run the server, it seems it cannot find the stylesheet. When I open the html file locally, it is able to find the CSS file.
Any ideas about how to fix this? I'm just using the link from W3schools that hosts the page, but I really need to edit and add my own parameters.
how did you tried to import your stylesheet in the link tag ?
did you write it something like that ?
<link rel="stylesheet" href="http://localhost:3000/client/w3.css" />
Use this in your app.js
app.use(express.static(__dirname + '/public'));
and add css like
<link rel="stylesheet" type="text/css" href="css/style.css" />
dont need / before css like
<link rel="stylesheet" type="text/css" href="/css/style.css" />
How can I include css files using node, express, and ejs?

How can I link CSS and HTML in different folders?

I have a stylesheet named style.css which is located inside a folder named css
And a HTML file named template.html in a folder named html
Both the folders are inside a folder named WebSite ( I guess that's the root folder. I'm new to html )
I want to link style.css to template.html using relative path.
My folder structure :
WebSite
|
|--css
|
|--style.css
|
|--html
|
|--template.html
|
|--index.html
I tried using
<link rel="stylesheet" href="../css/style.css" type="text/css" media="all" />
It didn't work
For more clarity I tried using view-source: before the url and clicked on the link but it showed
storage/emulated/0/WebSite/html/css/style.css (No such file or directory)
I am using Acode free app on Android mobile.
I have misread what you were actually asking for my fault. First I would test out linking the css sheet with a test html document to see if its something to do with the app. I dont know how "view source" works in this case but the view source is saying that your css folder, thus your css sheet is inside your html folder and according to your diagram explaining your folders, that is not true. In that case then your style sheet link would be <link rel="stylesheet" href="css/style.css" type="text/css" media="all"> An actual screenshot of your folder system , though not necessary, would be nice.

How to link css file in asp.net project?

I have Index.cshtml file and I want to include login.css file there. Index.cshtml lives on Views/Home. I created login.css file in Views/Home/css folder. Here is how I linked it on Index.cshtml:
<link href="css/login.css" rel="stylesheet" type="text/css">
But it doesn't work. When I writes styles inside Index.cshtml, it works perfectly. Where I made a mistake?
Typically you would not put your css in the Views folder. This would belong at the root of the website project(wwwroot). This way you would reference your external styles like this:
<link href="~/css/login.css" rel="stylesheet" type="text/css">
You can juste drags you file css file into yous cshtml file and VS to the work for u

I don't understand how absolute path works with local/remote hosts

I have my website project in /home/username/project with index.html in it. index.html has to contain the following .css file /home/username/project/css/application.css, so I try to load it like this:
<link rel="stylesheet" href="/css/application.css"/>
I run index.html page on my localhost and see no changes. Browser developer tools show me that style sheet doesn't exist in /home/username/css/application.css. Of course, because it is in the project folder, why does host trying to find it there?
You need to specify that the folder containing the css file in nested inside the folder containing your html file by putting a . before the path.
So your line becomes:
<link rel="stylesheet" href="./css/application.css"/>
For additional info, if you want to go the folder containing the folder of your html file, you have to put ...
So, for example, if your css file was in /home/username/css/application.css, your line becomes:
<link rel="stylesheet" href="../css/application.css"/>

How can I link my css file with my html in sublimetext 2?

My main doubt is the part of href.How can i avoid using the full link of the file as saved in my harddisk so that i dont need to change it while transferring through ftp.I also want to know how you can view your html files being developed that has been linked to different css files on your desktop web browser like chrome.
If your HTML file is stored in a directory, and your CSS files are stored, for example, in a css subdirectory, all you need to do is add
<link rel="stylesheet" type="text/css" href="css/mystyles.css">
to the <head> tags of your HTML file, and you'll be all set.
If the file is in the same folder as your HTML file you will simply type the name of the file
<link rel="stylesheet" type="text/css" href="style.css" />
Let's say that your style.css file is in another folder called css
<link rel="stylesheet" type="text/css" href="/css/style.css" />
By playing a "/" in front of your file name it is saying that it should look for the "css" folder starting from the root folder instead of the current location.
You can use relative paths. If the css stylesheet is in the same folder as the html use href="style.css". If it's in a folder that is in the same folder as the html use href="styles/style.css". If you need to go up a folder use href="../style.css".