Images and texts are displayed at different heights


You see, something fails to use table tags, because the texts are put at different heights, which affects even images.

HTML code:

{% for alfa in categoria %}
<img src="{% static alfa.foto %}"/>
<a href='{{}}'>{{alfa.nombre}}:<br/>{{alfa.descripcion}}</a>
{% if forloop.counter|divisibleby:cantidad %}
{% endif %}
{% endfor %}

CSS Code:

    color: #CCCCCC;
    display: block;
    text-align: center;
    border-collapse: separate;
    border-spacing: 5px;


How do I make all images look the same?

asked by Miguel Alparez 13.05.2017 в 11:37

2 answers


I know you say you have found a solution that will work using valign , but I would recommend that you not use it and instead do the same with CSS only.

The valign attribute is considered obsolete from HTML5 ( source ); This means that even if it works now, it is not guaranteed that it will work in the future (because it will stop supporting it). It would be better to use vertical-align in CSS .

So, the example that you put would not change its HTML but the CSS:

table td {
answered by 13.05.2017 / 15:58

Edit: I finally found the solution:

<td valign="top">
<img src="{% static alfa.foto %}"/>
<a href='{{}}'>{{alfa.nombre}}:<br>{{alfa.descripcion}}</a>

Too bad that being an internal variable of the tag, valign can not be passed to the css, forcing it to put it on each tag. Does anyone know if there is an alternative mode with css? Try something called "vertical-align", but fail.

answered by 13.05.2017 в 13:59