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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:14:15+00:00 2026-05-26T18:14:15+00:00

I have an input element inside a div element: … <div id=calculator-container> <input type=text

  • 0

I have an input element inside a div element:

...
<div id="calculator-container">
    <input type="text" />
</div>
....

In CSS I make the input width 100%:

#calculator-container {
    border: 1px solid black;
    background-color: lightgrey;
    width: 200px;
    padding: 10px;
}

#calculator-container input {
    width: 100%;
}

I can’t figure out why is there less free space on the right side of the input than on the left (please see the screenshot below). Maybe somebody can advise. Thanks.

Screenshot


Pointing out that on jsfiddle it looks fine but if you copy it locally it looks bad in both IE and Firefox. Here is the jsfiddle link just so you can copy the code: jsfiddle just to get the code

  • 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-26T18:14:16+00:00Added an answer on May 26, 2026 at 6:14 pm

    It’s because width means the width of the element’s content area. The <input>’s content area is surrounded by its padding and border.

    • http://jsfiddle.net/3f7RB/

    If you set those to 0, the input no longer takes up more space than is available:

    input {
        width: 100%;
        border-style: none;
        padding: 0;
    }
    
    • http://jsfiddle.net/3f7RB/1/

    (Of course, form elements are often rendered a bit differently from regular elements, so different browsers may do different things.)

    If you want padding on the <input>, you can either declare that as a percentage too:

    input {
        width: 96%;
        border-style: none;
        padding: 4px 2%;
    }
    
    • http://jsfiddle.net/3f7RB/5/

    Or use box-sizing (not supported in IE 6 or 7) so that width: 100% applies to the <input>’s content, padding and border combined:

    input {
        width: 100%;
        -moz-box-sizing: border-box;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
    }
    
    • http://jsfiddle.net/3f7RB/6/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input[type=radio] element inside a block container of fixed width. The supporting
I have an INPUT element of the TEXT type and I want to perform
I have an input type=file element with size=70 and width=522px . It looks and
I have an input inside a div element (id = edit). I was wondering
I have a div element: <div id=fruit-part> <input type=radio name=fruits value=apple>Apple <input type=radio name=fruits
I have saved input from a textarea element to a TEXT column in MySQL.
I have a div called divContainer inside which i have few input elements like
When users click search input element, the search text inside the input will disappear
I've got a bit of a css issue. I'm have a container div with
I have two input elements inside a div (a textbox and an image), intended

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.