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 8123155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:04:54+00:00 2026-06-06T06:04:54+00:00

Given a <select> and an <input> element, both specified to be 200px wide: <!doctype

  • 0

Given a <select> and an <input> element, both specified to be 200px wide:

<!doctype html>
<body>
<select style="width: 200px"></select><br/>
<input  style="width: 200px" type="text">
</body>
<html>

One ends up wider1,2,3, 4 than the other:

enter image description here

What is the reason for this?

If someone can give the reason, perhaps the solution would be obvious, and not a hack&pray.

Layout

The applied layout is perfectly reasonable:

enter image description here


Update 1: While i was writing this question Chrome updated itself from 17 to 19.

Update 2: Changing padding in the <input> from 1 to zero:

<!doctype html>
<body>
<select style="width: 200px"></select><br/>
<input style="width: 200px; padding: 0" type="text">
</body>
<html>

doesn’t make the <input> 200px wide (i.e. doesn’t fix it).

Update 3: Applying a CSS reset:

<!doctype html>
<head>
<style type="text/css">
   * {
       padding: 0;
       margin: 0;
   }
</style>
<body>
<select style="width: 200px"></select><br/>
<input style="width: 200px; padding: 0" type="text">
</body>
<html>

Does not solve the problem:

enter image description here

Also, i am less interested in a solution than an explanation.

Footnotes

  • 1,2,3 Chrome 1719, Firefox, Internet Explorer 9
  • 4 on Windows 7 64-bit

Bonus Reading

  • How to make <option> wider than <select> in IE6? (i don’t want the option to be wider than the select, i’m not using IE6)
  • How to show extended option in select list? (width of dropdown matches width of control)
  • HTML input element wider than Containing Div (no containing <div> here)
  • How to line up HTML input elements?
  • 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-06-06T06:04:56+00:00Added an answer on June 6, 2026 at 6:04 am

    Your <input> isn’t too wide; your <select> is too narrow!

    The real issue is that the <select> element doesn’t behave like most elements do. It uses a

    box-sizing: border-box;
    

    where width is the width of the element after padding and borders are applied; behaving as though it alone were in “quirks” mode.

    This runs counter to every other standards mode html element, which use:

    box-sizing: content-box; 
    

    To fix it, change the <select> to use the same box model as the rest of html:

    select { box-sizing: content-box; }
    

    OR change the <input> to use the same box model as the select:

    input { box-sizing: border-box; }
    

    The input element behaves like most elements do, using a content-box model, where the width is the width of the element before padding and borders are applied.

    There are default padding and borders set by your browser, so it is larger than you might want and/or expect. I always use a “CSS reset” at the top of my stylesheets, like so:

    * {
        padding: 0;
        margin: 0;
    }
    

    That will ensure there are no default padding or margins on any element.

    The select element is a different case though, where is behaves more like an element with box-sizing: border-box enabled, where it takes into account borders and padding into its width specification.

    If you add box-sizing: border-box to your input element, it will behave exactly as you expect/want.

    EDIT: Bolded the part that may be relevant to you. An alternate solution is reducing the specified width of the input element by a few pixels, so that it matches the width of the select box.

    Fiddle demonstrating both solutions: http://jsfiddle.net/n4yT2/2/

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

Sidebar

Related Questions

Given the following snippet of HTML: Goggles <input type=checkbox id=id_goggles_opt_in name=goggles_opt_in> Approved <input type=checkbox
I want to get the ID of an element which is <input type=text id='4711_herstellerName'
Given the following javascript: function foo(selectControl) { ... } and the following html: <select
I have the following html code: <div class=Radios> <span class=radio> <input type=radio value=1> yes
Given this HTML - how can I extend my jQuery to make the text
Let's say I have an html form. Each input/select/textarea will have a corresponding <label>
I want to be able to select all disabled decandants of a given element,
How to select all input with given name if name contains [ and ]?
Given the following: select * from a; select * from b; Are these two
Given this SQL: SELECT * FROM mytable ORDER BY mycolumn, RAND() Assuming that mycolumn

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.