'Why CSS file not working in my application? [duplicate]
I'm trying to use .css files in my project but it doesn't work. The directory hierarchy is: /resources/static/css/style.css. In my html file I tried
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Header</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href = "/css/style.css" th:href="@{/css/style.css}" >
</head>
but it does not work. What to do to make the style work? I read several articles but did not understand how to solve the problem
Solution 1:[1]
When using / at the start of your href address you are addressing from the root. so you should change the CSS link to this:
<link rel="stylesheet" href = "/resources/static/css/style.css" />
or just link it relatively with ./
for more information read this :
Solution 2:[2]
try to add type="text/css"
and adding dot to href="./your/location/style.css"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hootan |
| Solution 2 | Samculo |
