How to fix CSS file not linking to HTML document
Last updated:3rd Nov 2021
when you have link your CSS file in HTML, but your CSS file not work, then you need to take care few think.
If Both file present in same folder
if both files are present in the same folder then the correct way to link CSS in an HTML file is:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
If CSS file present in another folder
if CSS file present in another folder then you need to add CSS path properly. for example if your CSS file present inside current/assets folder i.e current/assets/style.css and your HTML file present inside current folder i.e current/index.html then add CSS in this way.
<link rel="stylesheet" href="assets/style.css">
make sure your Link tag is present in the right tag
the link tag of your CSS file must be present in the head tag