My HTML file does not connect to my CSS file. What for?

I cannot connect my CSS to my HTML file. I put the code below in my head at the top of my HTML file. I used the code on this website to connect my CSS to HTML: http://w3schools.com/tags/tag_link.asp

This is my HTML file:

<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="theme.css"> </head> <body id="whole-background"> <h1>Akhil Sharma</h1> <p>Official Website</p> </body> </html> 

and this is my css:

 #whole-background { background-color: #0099FF; } 

Someone please tell me how I can fix this problem.

+4
source share
3 answers

Save the file named theme.css in the same directory of the html page with your css rules

 #whole-background { background-color: #0099FF; } 
+1
source

Firstly, I myself close the link tag, for example:

 <link rel="stylesheet" type="text/css" href="theme.css" /> 

Then, make sure your stylesheet (theme.css) is in the same folder as the html file you are saving. This is in another place, for example, in a subfolder called "styles", then you will need to edit the path as follows:

 <link rel="stylesheet" type="text/css" href="styles/theme.css" /> 
0
source

To solve these problems, I highly recommend using Firebug . While you are using firebug, you can debug all kinds of problems. One of the main problems is why my CSS is not connected, or is it so, and I did not code it correctly. You can open firebug. Choose CSS TAB

enter image description here

And look at all the related CSS. You can also look inside the console to find out which error codes are appropriate, they are very detailed and save time.

enter image description here

This will help you deal with these issues. You do not have to use the btw link.

 <style type="text/css" src="theme.css"></style> 

It works just as well.

0
source

Source: https://habr.com/ru/post/1479914/


All Articles