+ 1

How do I link my css file to my html page on my device? I don't want to embed it into the head tag

Hello people, pls I need help. How do I put css code into my html page? I've already made the style in a css file on my device (.css) how do I link it to Html page? I've put embedded it into the head tag with <style>.... </style>, its making the overall code long, hence why I created the css file, but I'm having trouble linking them together.

21st Jul 2020, 10:14 AM
Akinpelumi Taiwo
Akinpelumi Taiwo - avatar
13 Answers
+ 6
Use the link tag.
22nd Jul 2020, 11:08 PM
Sonic
Sonic - avatar
+ 2
<link rel="stylesheet" href="your code.css">
21st Jul 2020, 10:19 AM
v@msi😉
v@msi😉 - avatar
+ 2
Thanks so much for this... And for taking the time to attend to me
21st Jul 2020, 11:09 AM
Akinpelumi Taiwo
Akinpelumi Taiwo - avatar
+ 1
Pardon me for that... Also thanks.
21st Jul 2020, 10:18 AM
Akinpelumi Taiwo
Akinpelumi Taiwo - avatar
+ 1
It's not working... Used <link rel="stylesheet" href="style.css /* cause that the title of the CSS */" type="text/css" >
21st Jul 2020, 10:22 AM
Akinpelumi Taiwo
Akinpelumi Taiwo - avatar
+ 1
Make sure that the style.css file is in the same folder as the html file. If it still doesn't work, this might help https://www.quora.com/Why-are-my-HTML-and-CSS-files-not-linking#:~:text=First%2C%20you%20need%20to%20make,to%20rel%3D%22stylesheet%22%20.
21st Jul 2020, 10:29 AM
XXX
XXX - avatar
+ 1
You can make a github or Dropbox (github is a bit complicated) account and store your CSS files there. Then you can use the link to import them in your HTML file. The only problem is, you will need an internet connection each time you need to run the HTML file. Just a side suggestion, coding here on sololearn is actually a better idea than locally on your phone, because first, you won't run into the problem you are in. And second, you can access your files from any device.
21st Jul 2020, 11:03 AM
XXX
XXX - avatar
+ 1
It's very simple...Just make sure you Stylesheet (CSS) is in the same folder with your HTML file then link your CSS to your HTML like this: <html> <head> <title> Hello world </title> <link rel="Stylesheet" href="style.css" /> </head> <body> <h1> Hello world </h1> </body> </html> The "rel" attribute tell's the browser that the link is to a Stylesheet. While the "href" tell's it the location and name of the Stylesheet (the URL of the Stylesheet)
22nd Jul 2020, 8:44 AM
Njoku Chisom Joseph
Njoku Chisom Joseph - avatar
21st Jul 2020, 10:17 AM
XXX
XXX - avatar
0
Already put it in the same folder, but Still not linking.. Thank you for the link by the way
21st Jul 2020, 10:35 AM
Akinpelumi Taiwo
Akinpelumi Taiwo - avatar
0
Are you sure you have put the link tag inside the <head> tag <head> <!-- some code --> <link rel="....... </head> If yes, are you working on a phone or a PC. I once had the same problem when working on a phone and I wasn't able to fix it or find solutions on the internet, so I eventually had to store my CSS files on the cloud (for example in dropbox or github)
21st Jul 2020, 10:42 AM
XXX
XXX - avatar
0
Working on a phone(don't own a pc at the moment) On Android by the way
21st Jul 2020, 10:50 AM
Akinpelumi Taiwo
Akinpelumi Taiwo - avatar
23rd Jul 2020, 3:50 AM
Thimuthu Pamuditha
Thimuthu Pamuditha - avatar