How to connect my HTML file with CSS file inside of a Django Project

I have a simple html page that works and renders properly on my local browser, but when I reference the static css file the page loads without the styling and I get a 200 Success for the url but 404 for the style.css file

I used

 <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}">

inside of the HTML file. I have the static folder in the correct spot at the project level and then a css file inside that followed by the style.css file.

The Html page:

{% load static %}
<!DOCTYPE html>

    <title>My Website</title>
    <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}">

                <li><a href="{% url 'home' %}">Home</a></li>
                <li><a href="{% url 'about' %}">About</a></li>
                <li><a href="{% url 'info' %}">Info</a></li>


The CSS page:

h1 {
    background-color: orange;

From the research I've done this should get the backgrounds of all the h1 tags orange but it is not working. Any Advice?

handle Static Files In dajngo


# 1 - Create (static) folder in Root Directory of Project
# 2 - Paste Your Static Files Folder in (static) Folder (js,css,images...etc)
# 3 - Now Do Setting in (
       STATIC_URL = '/static/'

       STATICFILES_DIRS = [os.path.join(BASE_DIR,'static') ]

       ---------- OR --------+

       STATICFILES_DIRS = [BASE_DIR / 'static']

# 4 - add {% load static %} tag on top of html page
# 5 - Now use ({% static 'assets/image.jpg' %}) tag in HTML File for calling static files
# 6 - Done

Thanks to the answers I was able to get an orange background for all the h1 tags. I added STATICFILES_DIRS = [BASE_DIR / "static"] to the file and it worked perfectly!

Back to Top