How to link CSS sheet in HTML

Question: I need to link a CSS sheet, but I cannot get it to work. Can someone help?

Repl link:

Within your header element, don’t put <style src="style.css"></style>, use <href="style.css" rel="stylesheet" type="text/css"/>, it may be counterintuitive but it’s just how HTML works.

1 Like

Where do I put it? When I do it in the head tag, it does nothing.

In the <head> element

I did that, and it did not work.

Are you sure it didnt work? Open it in a new tab, press “CTRL+ALT+I”, switch the the “Network” tab then refresh, it will have all of the resources that loaded

You can copy the CSS and paste it all in <style> tags and see if the CSS is the problem here. If you want to actually link a stylesheet, you do this:

<link rel="stylesheet" href=""`>


<link rel="stylesheet" href="/path/to/file.css"`>

in your HTML file. Put it in tags but it generally shouldn’t matter where you put it IIRC.

1 Like

Nope. Still didn’t work.

Are you sure, can you send me a screenshot of the network tab?

@Esb678 I forked your project and fixed it. You forgot the “link” part. To test, I made the background blue, and it works.

You can check the head part.


6 posts were split to a new topic: Can’t link CSS to HTML file