My CSS is not linking with HTML

I think the code is right too… External stylesheet not linking on replit I’m a new user

<link rel="stylesheet" href="/resources/mystyle.css"  type="text/css" />

Welcome to the community, @AlfiyaAnware!

You will need to change the <link> tag to:

<link rel=“stylesheet” href="{{ url_for('resources', filename='mystyle.css') }}" type=“text/css” />

im getting an error


werkzeug.routing.exceptions.BuildError: Could not build url for endpoint ‘resources’ with values [‘filename’]. Did you mean ‘renders’ instead?

Am I supposed to do something else as well?

Sorry for not mentioning this:

Since CSS is a static file, it should placed be placed inside the static folder with your home.html file.

Then change the href accordingly.

ok, i created a static folder and placed mystyle.css in it but since I’m using flask I have kept the html file in the templates folder. I’m not getting an error but the CSS attributes still havent been applied.

Also thank you so much for replying I really really appreciate the help as a beginner.

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

I figured out I had to use this.
Thank you so much for your help

Check out this SO post:

TL;DR place {{ url_for('static', filename='mystyle.css') }} instead of mystyle.css
EDIT: Make sure your placing this inside of the href property.

Here's why

Your flask project uses something called Jinja Templates. Jinja Templates are basically HTML with extra features. Since you can’t access code that’s on the server without telling the server to do so, you must place a special piece of text that tells the templating system to return the CSS file.