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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:16:06+00:00 2026-05-26T09:16:06+00:00

I realize this question is rather specific… I’m trying to get my head clearly

  • 0

I realize this question is rather specific… I’m trying to get my head clearly around the affects of “width” on the css box model.

I have a label to the left of two radio buttons. The label floats left, and the radio buttons appear to the right of the label. The radio buttons themselves have labels to the right of them, and these labels can be long.

The radios are in a UL block.

When I have width:auto; on the UL block, and then shrink the browser to be rather narrow, the radio buttons and their respective labels drop down to the next line.

If I remove the width:auto, the radio buttons remain floated and the label strings beside the radios continue to shrink, which is what I want.

My question is: Why would width:auto cause the radios and their labels to drop down a line? is it because width:auto attempts to create a box which accomodates the full length of the label strings without flowing the text? Or is something else at work?

Here’s sample code which demonstrates the behavior:

<style>
    .inlineLabels ul{
        float:left;
        width: 66%;
        padding: 0;
    }

    p.label{
        float:left;
        text-align:right;
        position:relative;
        width:32%;
        margin: .3em 2% 0 0;
        display:block;
    }

    ul.blockLabels{
        /*width:auto; why does uncommenting this cause the radios to drop down to a new line when shrinking browser size? */ 
        list-style:none;
    }
</style>
<fieldset class="inlineLabels">
    <div>
        <p class="label">Choose:</p>
        <ul class="blockLabels">
            <li>
                <label for="a-1">
                    <input name="a" id="a-1" value="0" type="radio">&nbsp;<span class="">A short string</span>
                </label>
            </li>
            <li>
                <label for="a-2">
                    <input name="a" id="a-2" value="1" type="radio">&nbsp;<span class="">A very very very  very very very very very very  very very very string</span>
                </label>
            </li>
        </ul>
    </div>
</fieldset>
  • 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-26T09:16:06+00:00Added an answer on May 26, 2026 at 9:16 am

    TLDR: the "preferred width" of floated elements with width auto is the width of the content without line breaks. That’s why the engine will first wrap the float and only as a last measure it will start wrapping text within the float.

    You can read the answer in the spec: http://www.w3.org/TR/CSS2/visudet.html#float-width

    If ‘width’ is computed as ‘auto’, the used value is the "shrink-to-fit" width.

    Calculation of the shrink-to-fit width is similar to calculating the width of a table cell using the automatic table layout algorithm. Roughly: calculate the preferred width by formatting the content without breaking lines other than where explicit line breaks occur, and also calculate the preferred minimum width, e.g., by trying all possible line breaks. CSS 2.1 does not define the exact algorithm. Thirdly, find the available width: in this case, this is the width of the containing block minus the used values of ‘margin-left’, ‘border-left-width’, ‘padding-left’, ‘padding-right’, ‘border-right-width’, ‘margin-right’, and the widths of any relevant scroll bars.

    Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width).

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

Sidebar

Related Questions

A rather specific question I realize, but I can't pinpoint this bug to either
I realize this may be a rather heretical question, but I wonder whether I
So I realize this question sounds stupid (and yes I am using a dual
I realize that this question is impossible to answer absolutely, but I'm only after
I realize that this question has been asked 100times but none that I have
I realize this perhaps a naive question but still I cant figure out how
I realize this is a basic question but I have searched online, been to
I realize that the query this question is looking for won't be enough to
I realize this is more of a hardware question, but this is also very
I realize this is probably a hopelessly newbie question, but what is the difference

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.