I have some HTML which is equivalent to the following:
<div style="border: 1px solid black">
<fieldset style="margin: 0">
<legend style="margin-top: 20px;">testing....</legend>
</fieldset>
</div>
My question is why does the margin-top
on the legend not render? I’d like to fix the issue with CSS only. Thanks!
2
Answers
If you really want to do this, then set
legend { float: left; }
:Try padding instead. And it will work.
The reason why margin doesn’t work because the distance between the border and the text content is called padding not margin.
I am no sure what exactly you are looking for. But you can also try padding in the container and vertically center the text within the container if that’s what you want.