I cant click on image url in Django

Viewed 20

So I wanted to have this logo in the blog app, which was going to be part of each page, so users can always click on it, and ideally, when they click on it, it shall lead them to a page with articles. So this the code that I written in base file, but for some reason its not clickable: base.html

{%  load static %}
<!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>Articles</title>
    <link rel="stylesheet" href="{% static 'styles.css' %}" >
</head>
<body>
    <div class = "wrapper">
        <h1><a href = "{% url 'articles:list' %}"> </a><img src="{% static 'article.png' %}"/> </h1>
        {% block content %}
        {% endblock %}
    </div>
    
</body>
</html>

Any suggestions how to fix it?

2 Answers

Please keep image src inside your anchor tag

 {%  load static %}
    <!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>Articles</title>
        <link rel="stylesheet" href="{% static 'styles.css' %}" >
    </head>
    <body>
        <div class = "wrapper">
            <h1><a href = "{% url 'articles:list' %}"> <img src="{% static 'article.png' %}"/></a> </h1>
<!--changes here-->
            {% block content %}
            {% endblock %}
        </div>
        
    </body>
    </html>

logo image should be into anchor:

<h1>
    <a href = "{% url 'articles:list' %}" title="????">
        <img src="{% static 'article.png' %}" alt="????" />
    </a>
</h1>

please don't forget alt for image and title for anchor, to made your page better for peoples with "barriers"

Related