How to style HTML in flask

Question:

So I want to style a HTML page on flask but apparently it odesn’t seem to work
Repl link:


templates/index.html:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>replit</title>
  <link href="static/css/style.css" type="text/stylesheet" rel="stylesheet">
</head>
<body>
  <h1 id="title">Username + Password Flask Authentication</h1>
  <button onclick="window.location.href='/register';">
      Register
  </button>
  <button onclick="window.location.href='/login';">
      Log In
  </button>
</body>
</html>

Could you please send a link to the Repl?

https://replit.com/@SnakeyKing/Username-Password-Authentication#templates/index.html

Try changing the href to ../static/css/style.css.

So <link href="../static/css/style.css" type="text/stylesheet" rel="stylesheet">?

Still not working :frowning:

Try

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

It’s still now working :sob:

try to change from:

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

To

<link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.