Despite my efforts to link the stylesheet properly, the resulting page does not display any styling. HTML:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
test test test
</body>
</html>
CSS:
@charset "UTF-8";
body {
background-color: #f25f29;
}
Both files are located in the same folder named test
inside the xampp htdocs
directory. Interestingly, another website with a stylesheet from a book in a different subfolder within htdocs
displays fine. I tried comparing my page to the working one but couldn't identify the issue.
I have attempted the following fixes:
- Trying different paths
style.css
./style.css
/opt/lampp/htdocs/test/style.css
file://opt/lampp/htdocs/test/style.css
/test/style.css
(assuming localhost uses htdocs as root)file://test/style.css
- Ensuring
charset
specifier matches in CSS and HTML files (all uppercase) - Closing the link using
/>
instead of>
- Adding a space between linkname and closing bracket
sudo chmod 777 *
in the test folder (reverted back to 644)- Restarting xampp
- Removing the
type="text/css"
specification - Double-checking the stylesheet name and path
- Avoiding enclosing the link in
<style>
tags - Using straight quotation marks instead of italic ones
The version that works for the other case is provided above.
Edit: Clearing the cache fixed the issue, as suggested in the comments.