{% if messages %}
<div class="container mb-3 mt-3">
  {% for message in messages %}
  <div class="alert {% if message.tags %}alert-{{ message.tags }}"{% endif %}>
    <button type="button" class="close" data-dismiss="alert">×</button>
    {{ message }}
  </div>
  {% endfor %}
</div>
{% endif %}

{% load i18n %}

{% if messages %}
<div class="container mb-3 mt-3">
  {% for message in messages %}
  <div class="alert {% if message.tags %} alert-{{ message.tags }}{% endif %} alert-dismissible fade in" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="{% trans "Close" %}">
      <span aria-hidden="true">×</span>
    </button>
    {{ message }}
  </div>
  {% endfor %}
</div>
{% endif %}

Improve accessibility of alert close button
Improve accessibility of alert close button