+ 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.
13 Answers
+ 6
Use the link tag.
+ 2
<link rel="stylesheet" href="your code.css">
+ 2
Thanks so much for this...
And for taking the time to attend to me
+ 1
Pardon me for that...
Also thanks.
+ 1
It's not working...
Used <link rel="stylesheet" href="style.css /* cause that the title of the CSS */" type="text/css" >
+ 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.
+ 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.
+ 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)
0
This question has already been asked many times before. Please use the search bar before posting a question
https://www.sololearn.com/discuss/1505815/?ref=app
https://www.sololearn.com/discuss/133450/?ref=app
https://www.sololearn.com/discuss/1249913/?ref=app
https://www.sololearn.com/discuss/510697/?ref=app
0
Already put it in the same folder, but Still not linking..
Thank you for the link by the way
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)
0
Working on a phone(don't own a pc at the moment)
On Android by the way