How to set the same width for input and select fields with CSS?

Spread the love

Sometimes, we want to set the same width for input and select fields with CSS.

In this article, we’ll look at how to set the same width for input and select fields with CSS.

How to set the same width for input and select fields with CSS?

To set the same width for input and select fields with CSS, we select both elements and set them to the same width.

For instance, we write

select,
input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}

to select the select and text input elements with the selectors.

And then we set their widths to 100% with width: 100%;.

Conclusion

To set the same width for input and select fields with CSS, we select both elements and set them to the same width.

Leave a Reply

Your email address will not be published. Required fields are marked *