Following code for a 'form' wrapped in a 'div' works correct:
<div>
Please logout with a Click:
<form style="display: inline-block;">
<input type="hidden" name="var1" value="val1">
<button type="submit">Logout-Button</button>
</form>
</div>
Note: The form is styled as inline-block
. The code is placed in a <div>
.
Wrapped in the <div>
this works proper and on the page this show up correct in one line:
Please logout with a Click: [Logout-Button]
But changing the wrapper from 'div' to 'p' leads to an unexpected behaviour:
When the form is wrapped in a <p>
instead of the <div>
the button breaks to a new line:
The code ...
<p>
Please logout with a Click:
<form style="display: inline-block;"> ... </form>
</p>
Results in ...
Please logout with a Click:
[Logout-Button]
(Same behaviour when I use inline
instead of inline-block
to style the form.)
I wonder about:
- As
<div>
and<p>
are both Block-Elements: what is the basic reason for this unexpected different behaviour in<div>
and<p>
? - Does anyone know a simple CSS-Solution to make the 'inline-view' of the form/button working in a 'p-tag'?
Thanks for any hints and answers!