0

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

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49

2 Answers2

0

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 :

having-links-relative-to-root

Rocky
  • 117
  • 1
  • 1
  • 9
0

try to add type="text/css"
and adding dot to href="./your/location/style.css"

Samculo
  • 89
  • 3