Jump to content

Hey guys so im trying to link my CSS to my HTML file, i did have it and it worked but now some else has caused it to break. They are both in the same folder(they were in different folders but i moved the css to fix it).

<head>
        <meta charset="utf-8">
            <title>Random Title</title>
                <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
    </head>

 

My css is called stylesheet and i already have code in it if you want to see it.

Also does anyone know any good live browers viewers from Atom.io

Link to comment
https://linustechtips.com/topic/865618-cant-link-html-with-my-css-file/
Share on other sites

Link to post
Share on other sites

Is that slash there in your code? It shouldn't be.

 

<link rel="stylesheet" href="file:///D:/TestHTML/css/homepage.css">

 

This is what mine looks like, and works. Obviously you'd get rid of all the file path if they're in the same folder, just that mine doesn't have the slash that yours does at the end.

.

Link to post
Share on other sites

6 hours ago, AlwaysFSX said:

Is that slash there in your code? It shouldn't be.

 


<link rel="stylesheet" href="file:///D:/TestHTML/css/homepage.css">

 

This is what mine looks like, and works. Obviously you'd get rid of all the file path if they're in the same folder, just that mine doesn't have the slash that yours does at the end.

100% the wrong way to link a css file. You use the relative path like op has so that it will work on other places other than your pc. 

 

6 hours ago, JimmyJimJam said:

Hey guys so im trying to link my CSS to my HTML file, i did have it and it worked but now some else has caused it to break. They are both in the same folder(they were in different folders but i moved the css to fix it).

<head>
        <meta charset="utf-8">
            <title>Random Title</title>
                <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
    </head>

 

My css is called stylesheet and i already have code in it if you want to see it.

Also does anyone know any good live browers viewers from Atom.io

try holding control and pressing f5, this hard reloads making sure the browser uses the ones on the server and not ones in its cache. 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

1 hour ago, vorticalbox said:

100% the wrong way to link a css file. You use the relative path like op has so that it will work on other places other than your pc. 

My site is completely local, it's 100% the best way to have everything linked for less headaches in my case. ;) The entire point of just copying and pasting it was that I don't have the slash at the end of my code.

.

Link to post
Share on other sites

8 hours ago, AlwaysFSX said:

My site is completely local, it's 100% the best way to have everything linked for less headaches in my case. ;) The entire point of just copying and pasting it was that I don't have the slash at the end of my code.

No. That isn't how you're supposed to do it. just because it works doesn't mean you should do it. 

 

The whole point of having relative links is that it will work no matter where you put your code. If you moved that website to another folder or to another computer you would have to re do every single js, css, img and everything else for it to work.

 

There is a reason why the web standard uses relative links because its the right way to do it. 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

7 minutes ago, vorticalbox said:

No. That isn't how you're supposed to do it. just because it works doesn't mean you should do it. 

 

The whole point of having relative links is that it will work no matter where you put your code. If you moved that website to another folder or to another computer you would have to re do every single js, css, img and everything else for it to work.

 

There is a reason why the web standard uses relative links because its the right way to do it. 

It's project code, I have it for sanity when linking stuff from different drives in my computer so I can see where something is located without digging through a flowchart or folders.

 

I'm very well aware of using relative links for literally everything else, this is the only case I don't. I'm not doing it in this specific case for a reason.

.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×