Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4320914
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:41:09+00:00 2026-05-21T08:41:09+00:00

I have an input field on a page that looks something like this: <input

  • 0

I have an input field on a page that looks something like this:

<input type="text" size="20" name="whatever" />

Imagine that I wanted to keep the size attribute and not use CSS instead, and that I wanted to now add a select box to the same form of the same width:

<select name="whatever2">
  <option>an option</option>
</select>

What attribute should I add to get the select box to match the width of the input field?

I initially thought ‘size’ but no – that’s the number of options to display, second thought was ‘style=”width:20em”‘ but it’s bigger…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T08:41:09+00:00Added an answer on May 21, 2026 at 8:41 am

    From the spec:

    size = cdata [CN]

    This attribute tells the user agent the initial width of the control. The width is given in pixels except when type attribute has the value "text" or "password". In that case, its value refers to the (integer) number of characters.

    So size for text and password fields represents the number of characters – it’s not used to define the pixel width. Depending on the font used to style the input field, the pixel width of the field may differ.

    For this field:

    <input type="text" size="25" name="firstname">
    

    The browser will by default render it wide enough to fit 25 characters.

    Now, you could theoretically use the above information to determine what width to give it in CSS, but I haven’t bothered with that myself yet. Besides, as oft-noted, how form elements are rendered on pages varies widely from browser to browser, so it may not be a reliable way to size your fields.

    Remember that setting a width using CSS always overrides the size attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that looks like this: <form action=/assesment/savelist/ method=post> <input type=hidden name=owner
I have a field on my page, like this: <input type=hidden name=myField id=myField />
I have a hidden input field on a page <div id=SomeDiv> <input type=text name=ID
I have an input field that is by default set to type=text so that
I have a page that's setup with an input text field hidden with display:
I have a input field with a name attribute like field[subkey][subkey2] How can I
I have one input field and one division with span children <input type=text id=input
I have an input field whose name is an MD5 string e.g.: <input type=hidden
For instance, I want to have a html form that looks like this: <table>
hey guys, I have an input field that looks for matched characters on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.