Description
Today I asked on Twitter
If you could specify some CSS to make a
<legend>
act like a normal element, what would it be, ideally?
https://twitter.com/zcorpan/status/1028999908433571846
answers so far
It feels that should be the role of
display: block
ordisplay: inline
(It's display: block by default. Sites change the display value (to inline-block, table...) and expect the magic legend rendering.)
Given that the magic rendering of occurs only inside
and the latter has other "magic" rendering features (e,g, BFC root and min-width: min-content; by default), maybe it would be better to "turn off" this "magic" on the level?
I would try
appearance: none
, like many others, only for .
appearance: none
? And by default it would haveappearance: legend
?
first thing that comes to mind is setting "appearance" to "none" but i admit that i'm a little ignorant to the history of that property
Yeah, it definitely makes sense for this to be on
<fieldset>
. Could maybe be useful to also have it on<legend>
, but inherit the value from<fieldset>
, to allow for keeping the special styles on<fieldset>
without the special placement of<legend>
.
(Just for clarification, I think I've always removed browser styles from
<fieldset>
and<legend>
at the same time, so I personally wouldn't needappearance
on<legend>
if it were on<fieldset>
, and definitely would want it on<fieldset>
. But someone else might need it on both?)
appearance: none is what I thought about before writing the tweet, also. Since float and position:absolute/fixed on the legend disentangles the legend, I thought appearance: none would go on the legend, but I suppose it could go on the fieldset instead.
Any preference on the implementation side, if we are to do this? cc @bzbarsky