Skip to content
← Back to Community
(solved)HTML & CSS linking
Profile icon
ZControls_Games

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 but it still doesn't work.

Any help would be much appreciated.

Voters
Profile icon
izzyjazz
Profile icon
Tycho112
Profile icon
UtsavAchar
Profile icon
alvessdan
Profile icon
138suzie
Profile icon
DiegoNelson1
Profile icon
SudhanvaUdupa
Profile icon
Etrusco
Profile icon
abdullahmah1
Profile icon
mehdiAfoutouh
Comments
hotnewtop
Profile icon
coderash

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.

Profile icon
ZControls_Games
Profile icon
AtharvaSingh007

Awesome dude worked like a charm

Profile icon
Galamphin

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 and )

Profile icon
ZControls_Games

@Galamphin Ok, I will try that.

Profile icon
ZControls_Games
Profile icon
ArchieMaclean

Do you have a link to the repl?
Is the link between the <head> tags?

Profile icon
ZControls_Games
Profile icon
ZControls_Games
Profile icon
fifiinart

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.

Profile icon
AllenThomas3

Try writing this then <link rel="stylesheet"href="style.css">

Profile icon
TheDrone7

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

Profile icon
ZControls_Games
Profile icon
ZControls_Games
Profile icon
TheDrone7

@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.

Profile icon
ZControls_Games

@TheDrone7 OMG THANKS

Profile icon
TheDrone7

@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.

Profile icon
ZControls_Games

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

Profile icon
TheDrone7

@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.

Profile icon
LarryMoe

@TheDrone7 I would agree, I use W3Schools a LOT, its amazing for learning new things

Profile icon
ZControls_Games

@LarryMoe Yh I currently use it a lot now.