Linking css file to html file - html

hi I am having a problem of lining my css file in my html file when I include the css file in a separate folder and link it to html by providing the directory and folder name it does not work but when I take the css file out of the folder and then link it it works then

files inside folders can be tricky. Lets say you have the following.
folderA >>
fileA.css
index.html
File A is inside of Folder A. To get to it, you would need to insert the following into your html code:
<link rel="stylesheet" href="./folderA/fileA.css">
You can change the file/folder names to suit your needs, as you have not specified the exact names.

Related

How do I link to a CSS file that is in another folder, from within a subfolder?

I am working on programming a very basic show streaming site for a project, and I have multiple folders. Folders include:
HTML
CSS
Shows
Inside of the "Shows" folder, I have a subfolder called "Testshow".
How do I link a CSS file from the CSS folder into an html file in the Testshow folder?
I have tried
<link rel="stylesheet" href="/css/style.css">
and some other things, but nothing has been working.
try something like this from your html file ../css/style.css
../ it means one folder up
../../ it means two folder up
Thank you #Konstantin Savusia !
I used ../ before asking and it didn't work, but what you recommended did work!
I just added ../../ to the beggining.

CSS External File is linking to the my html file from its own folder

Not sure why the external file not working?
It works ONLY if I created it in the same folder with my HTML, but when I created the CSS with its own folder it's not working. I'm asking because it works for other classmates but me.
Try giving the css path as
link rel="stylesheet" type="text/css" href="../css/styles.css">
To get to the css folder you will need to go back one folder level which can be done with ../.
In this case you could change your href to href="../css/styles.css".
Or
Because css is at the root of your project you could use href="/css/styles.css".
Or
You should take your HTML files out of the /image folder and into the root of your project in HTML - Personal Site/ and then you won't have to change the href property

Problem with html and css linking them together

I just started using html and css and I have to do something with it but I am getting the error Unable to open 'style.css'. I don't know what the problem is since the path that I used is the same as the file path.
Make sure the CSS file and the HTML file are in the same folder.
based on your image it should be
href="mywebs\site\style.css"
if you want to link site/style.css to mywebs/smth.html you should go one folder back.
<link href="../site/style.css">
or put the site folder inside mywebs, because based on the picture the site folder is not inside mywebs folder.
Sometimes the file may missed directory. You can close and open the code editor and it will work. Also, make sure your html and css file is in same directory. If you css file is in a different directory then use the following code:
<link type="text/css" href=".../style.css"/>

Why is my html file not linking to my CSS layout?

I am using XAMPP and MyPHPadmin to setup a survey with a database that I will be using for a project.
Now I am trying to link my css file to my html file so that the layout changes. I am trying to link this with:
<link type="text/css" href="/Versie1.1/default.css" rel="stylesheet">
My css file is located at: C:\xampp\htdocs\Versie1.1\default.css
I have tried a lot of different hrefs as in: "default.css", c path to the default.css, etc.
Any idea why my layout is not changing to the one in the css file? If I put the css code inside the <head> it does work.
it's seems, some path problem.
If your porject file path is "C:\xampp\htdocs" in this path you have one folder 'Versie1.1' and a html file index.html, then your "href=Versie1.1/default.css"
file structure
Versie1.1
default.css
index.html
file structure
Versie1.1
default.css
html
index.html
In this case link will be "href=../Versie1.1/default.css"
I hope you understand. Thank you!

How to reference external css file in file manager - Domain.com

I'm having trouble referencing an external css file in my file manager. My html page is in a folder called "homepage" and my css file is in a folder called "library".
Currently, I have
<link rel="stylesheet" href="library/homepagecss.css">
but that won't reference the css file.
My only option is to have the homepage html file and css file in the same folder but i'd like to have them separated for organization.
Anyone know how to do this in Domain's file manager?
You should either write an absolute path there, like
<link rel="stylesheet" href="C:/User/Documents/public_html/library/homepagecss.css">
(I am assuming your path to the current directory)
BUt if I understood well your both folders library and homepage are in the same folder called public_html you can try this one
<link rel="stylesheet" href="../library/homepagecss.css">
By entering .. you go up in the directory tree, you go up at the parent directory, and you need to go up at public_html cause there is where you library folder is located.
If the homepage of your site is at example.com, and your homepage is in a “homepage” folder, then the href you currently have is going to be looking for a file at example.com/homepage/public_html/library/homepagecss.css. And that’s obviously not correct.
You have two options to fix it.
Use an absolute path to the CSS file: href="http://example.com/library/homepage.css"
Use the HTML <base> tag to set your base path as your homepage in the <head> of your site, and then specify the relative URL in the link to your stylesheet: href="/library/homepagecss.css"