Linking my CSS and font file

I am unable to link the css and font file.
The possible reason I think is my file directory i.e. My file directory is like C:/Users/User Name1/file file1/…

It contains spaces from folder name.

Can anyone suggest me the possible solution to it.

P.S. I use normal notepad for writing code as my professor had strictly warned us not to use any IDE.

Save the CSS and HTML document in the same folder, that might help…

how so? use stylesheet or javascript in html files are done by relative path, meaning if they are inside the same folder, path will be link=“fileName”

What I am trying to say is that when the CSS file is in the same folder the link will be short and there are fewer chances of the path having an error.

1 Like

Sorry to be Johnny-come-lately here but for posterity:

RE: Notepad vs IDE

While your prof has warned against an IDE he probably didn’t warn against using a better text editor… Notepad is a last-resort in my opinion - there are MANY other editors that are far superior and will provide you with things like syntax highlighting, automatic tag closing, code help “intellisense” and more. My personal choice is Notepad++ or better yet VS Code.

RE: Filenames…

I generally find it bad form to include spaces in file names exactly for the reasons you just experienced… Modern browsers and server do a MUCH better job than they once did but it’s generally just a headache you can avoid by omitting spaces.

That said, you can and should make sure that your filename in the href of your link tag is enclosed in quotes otherwise it won’t work:

<link rel=“stylesheet” href=“my stylesheet.css”> <!-- works great -->
<link rel=“stylesheet” href=my stylesheet.css> <!-- doesn’t work -->

RE: File paths…

Always use relative paths an not fully path. This makes everything “portable” and easy to move…

<link rel=“stylesheet” href="…/stylesheets/style.css"> <!-- works “everywhere” -->
<link re=“stylesheet” href=“file://C:\My documents\my website\stylesheets\style.css”> <!-- only works on YOUR machine (on another machine with IDENTICAL file structure) -->

Hope someone finds some of this helpful!

1 Like