Curious about CSS. I was under the impression that setting width:auto
for a display:block
element would make it 'fill available space'. However, when applied to an <input>
element, this doesn't seem to hold true. For instance:
<body>
<form style='background:red'>
<input type='text' style='background:green; display:block; width:auto'>
</form>
</body>
I have a couple of questions:
Is there a clear definition of what
width:auto
actually means? The CSS specification appears ambiguous to me, but I might have overlooked the relevant section.Is there a method to achieve the desired behavior for an input field - i.e., filling available space like other block-level elements do?
Thank you!