Ask coding questions

← Back to all posts
(solved)HTML & CSS linking
ZControls_Games (16)

I have an inquiry!
So I want to know how to link both CSS and html so that when I use CSS it styles html but it's not working.I have tried <link rel="stylesheet" type="text/css" href="stlye.css"> but it still doesn't work.

Any help would be much appreciated.

Commentshotnewtop
Galamphin (101)

When you make a new HTML,CSS,JS repl it automatically connects them, but if your not then the code you've written above should work (just remember to put it between <head> and </head>)

fifiinart (8)

First check if everything is spelled correctly.

So not href="stlye.css" but href="style.css.

Then, does the file exist?

If these don't work...just use a <style> tag. It's ugly, but it works.

coderash (66)

You have to use a <link href="#yourcssfile" rel="stylesheet" type="text/css"> inside the <head></head> tag (It contains all program preferences, fonts and plugins) if you want it to look neat.

TheDrone7 (560)

Could we have a link to your repl, so we can make sure? Since IIRC that is the way to do it.

TheDrone7 (560)

@ZControls_Games It's actually a very funny mistake, just a little typo, in your code you wrote the file name as stlye.css while it's actually style.css

Please upvote if this helps.

TheDrone7 (560)

@ZControls_Games you're welcome lol.

Also to everyone else. It's not compulsory to put the <link> tag inside <head> it works even if you keep it in body. IIRC, it will apply the styles to the tags that come after it.

ZControls_Games (16)

@TheDrone7 I have another question...How would you link javascript to html?

TheDrone7 (560)

@ZControls_Games there's a src attribute to the script tag which you can use. Also, refer to w3schools for things like this. It's perfect for beginners.