Why put input hidden field in display:none style?

Hello,
In Django framework, I find the hidden forms fields in a div style=“display:none”

For example for the security token

<div style=“display:none”>
<input type=“hidden” name=“csrfmiddlewaretoken” value=“894yb3poe6de233c6b3742685a98472f”>
</div>

I want to know the reason, because in any case, all fields of type hidden are not visible.

Thank you.

There is no reason.

The basic reason behind using hidden fields is to pass some value in PHP, which you do not want to be shown in your webpage directly. And the person used style to hide the Div box, to hide it too… There is no big deal with it.

Many people use Hidden input types to pass a large number of variables according to needs :slight_smile:

Okay, so put the hidden DIV box is useless since the field is already hidden type.

correct, hidden inputs are … hidden from the page :wink:

yes, that’s useless… unless you have some css styles applying at default Div tag… if that is the case, you will need this div with style… again, only if you feel the need to have a DIV there :smiley:
that’s pretty funny, am i stressing too much ? :slight_smile: :wink:

That does seem rather redundant. It is possible, however that i was done so as to be able to put the input there (for some on known reason) while not disturbing the flow of other elements. Still… odd

As discussed here (among others) in older browsers (i.e., legacy IE) hidden input fields took up some space. Wrapping them in a display: none div makes sure they’re completely invisible and don’t take up any space.
Indeed I’d say that nowadays this is no longer needed as all browsers render hidden inputs correctly now.

Thank you for your answers.
PS: I just noticed that Django is also the same for its security token, it’s weird that they add a box hidden div to keep compatibility with older browsers and it support the HTML5 which is not compatible with the older web browsers.