Style input element to fill remaining width of its container

Let’s say I have an html snippet like this:

<div style="width:300px;">
    <label for="MyInput">label text</label>
    <input type="text" id="MyInput" />
</div>

This isn’t my exact code, but the important thing is there’s a label and a text input on the same line in a fixed-width container. How can I style the input to fill the remaining width of the container without wrapping and without knowing the size of the label?

8 Answers
8

Leave a Comment