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

  • Home
  • SEARCH
  • 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 3626610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:47:02+00:00 2026-05-18T23:47:02+00:00

Sample HTML/CSS: <div class=container> <input type=text /> <div class=filler></div> </div> div.container { padding: 5px;

  • 0

Sample HTML/CSS:

<div class="container">
    <input type="text" />
    <div class="filler"></div>
</div>

div.container {
    padding: 5px;
    border: 1px solid black;
    background-color: gray;
}

div.filler {
    background-color: red;
    height: 5px;
}

input {
    display: block;
}

http://jsfiddle.net/bPEkb/3/

Question

Why doesn’t the input box expand to have the same outer width as, say div.filler? That is to say, why doesn’t the input box expand to fit its container like other block elements with width: auto; do?

I tried checking the “User Agent CSS” in Firebug to see if I could come up with something there. No luck. I couldn’t find any specific differences in CSS that I could specifically link to the input box behaving differently from the regular div.filler.

Besides curiousity, I’d like to know why this is to get to the bottom of it to figure out a way to set width once and forget it. My current practice of explicitly setting the width of both input and its containing block element seems redundant and less than modular. While I’m familiar with the technique of wrapping the input element in a div then assigning to the input element negative margins, this seems quite undesirable.

borkweb and Phrogz have both provided exceptional information that takes advantage of the border-box box model from the old days. Thanks for this! I’d like to reiterate the focus of my question that I intend to keep distinct from the proposed solution to my practical problem:

What about the specification causes input boxes to be formatted unlike ordinary block elements like divs? The border-box solution is wonderful, but it doesn’t satisfy the desire to figure out why input boxes are this way in the first place and why they can’t be made to behave exactly like ordinary divs, which do not use the border-box model these days.

  • 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-18T23:47:03+00:00Added an answer on May 18, 2026 at 11:47 pm

    Alright, due to the clarification of the original question…I did some digging and found these laments and this article.

    There are a few elements (<input>, <select>, <button>, <img>, <object>, and <textarea>) that are considered replaced elements whose appearance and dimensions are defined by an external resource. (e.g. the operating system, a plugin, etc)

    Replaced elements can have intrinsic
    dimensions—width and height values
    that are defined by the element
    itself, rather than by its
    surroundings in the document. For
    example, if an image element has a
    width set to auto, the width of the
    linked image file will be used.
    Intrinsic dimensions also define an
    intrinsic ratio that’s used to
    determine the computed dimensions of
    the element should only one dimension
    be specified. For example, if only the
    width is specified for an image
    element—at, say, 100px—and the actual
    image is 200 pixels wide and 100
    pixels high, the height of the element
    will be scaled by the same amount, to
    50px.

    Replaced elements can also have visual
    formatting requirements imposed by the
    element, outside of the control of CSS;
    for example, the user interface controls
    rendered for form elements.

    W3C’s CSS 2.1 “Visual Formatting Model Details” section discusses the calculation of widths of both replaced and non-replaced elements.

    Overall…pretty annoying for some form elements (<textarea>, <button>, and <input>). Can/will it change? Probably not any time soon…Until it does change at the core, we’ll have to stick with the hacks 🙁

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

Sidebar

Related Questions

I have some very simple HTML: <div id=advisor> <div id=print_this_container> <form> <input type=button value=
I'm trying to style all html with the class called sample <div class=sample> </div>
We have a rather simple site (minimal JS) with plain html and CSS. It
I have a very simple html. The red div is inside the blue div
I have a simple html page with a div. I am using jQuery to
I'm 10 lines in to my second attempt at HTML and CSS and it
I'm building a simple shoutbox. Here's the html : <div id=shoutbox> <form method=post id=form
I've done a simple menu using some HTML, CSS and Javascript. The main idea
I have a simple HTML. I am using the JQuery for AJAX purpose. Now,
I have a simple html block like: <span id=replies>8</span> Using jquery I'm trying to

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.