So I have an html file and a css file (shortened examples shown here) and for some reason when I open the html file the css file does not run and there are also no errors in the console. I have tried looking at several different answers to similar questions but none of them are changing anything. The two files are in the same folder.

index.html <!DOCTYPE html> <html> <head> <link res="stylesheet" type="text/css" href="./style.css"> </head> <body> <h1>Hello World</h1> </body> </html> style.css h1 { text-align: center; }

I am using chrome and the files are stored locally on the computer

Joseph K's user avatar

2

Your CSS isn’t loading because of a typo in the <link> tag.

You wrote res instead of rel. Browsers don’t throw an error for this, they just ignore the stylesheet.

Fix:

<link rel="stylesheet" href="./style.css">

After correcting that, refresh the page (Ctrl + F5) and the CSS will apply.

Hemant Mhalsekar's user avatar

1 Comment

the correct code is "<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1>Hello World</h1> </body> </html>" there is the typo error in it and the "rel" is not written, the page is not having the css applied in it.

2026-01-09T05:32:34.927Z+00:00

the correct code is "<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1>Hello World</h1> </body> </html>" there is the typo error in it and the "rel" is not written, the page is not having the css applied in it.

Adnan_Abid's user avatar

New contributor

Adnan_Abid is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

The file must be in the same folder as index.html, but for “./” to work, you must set up a localhost server. If you are only opening the HTML file by double-clicking, the easiest thing to do is to leave it in the same file, but leave the import as href="style.css".

Igor McLven's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.