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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:51:24+00:00 2026-05-16T07:51:24+00:00

That is, without defining a specific ‘width’ amount for each individual item. As in,

  • 0

That is, without defining a specific ‘width’ amount for each individual item. As in, the widest element (by its content) sets the width for each of the other elements.

Additionally, how do I span said list 100% across its container, also keeping each item the same width?

  • 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-16T07:51:25+00:00Added an answer on May 16, 2026 at 7:51 am

    If I understand correctly:

    1. You want a list.
    2. You want each list item to be the same width.
    3. You want that width to be the width of the widest list item’s content

    4. You also want a way to evenly space list items across a container,
      this seems incompatible with 3, because then they won’t be evenly spaced by content but by container size.

    So I’m assuming you want two different solutions.

    I think you can do

    <style>
      ul, li{float:left;margin;padding:0;display:block;}
      li {clear:left;width:100%;margin:1px 0;background:#03a;}
    </style>
    <ul>
      <li>Item 1</li>
      <li>Item 2 which is longer</li>
      <li>Item 3</li>
    </ul>
    

    works in some browsers. I seem to remember it not working in IE, and having to make it work using css expressions.

    The idea is that the ul and li’s are floated to shrink them to their content width.
    The li’s are cleared and set to 100% of their container width, the same container that is shrunk to their size.

    —

    Your other option is impossible in CSS unless you know the number of list items.
    Though if you don’t know the number of list items it means there is scripting going on either server side or client side, and you can find out the number of items. 🙂

    I’ve solved this in the past by giving the ul a class with the number of children in it, and using lots of CSS rules and hoping one sticks.

    eg

    <style>
      ul.lis1 li {width:100%}
      ul.lis2 li {width:50%}
      ul.lis3 li {width:33.3%}
      ul.lis4 li {width:25%}
      /* ... you can keep going forever here, though there'll be a point at which they become too thin and your UI breaks anyway, */
    </style>
    <ul class="lis4"> <!-- lis4 is generated by PHP or Ruby or whatever -->
      <li>item 1</li>
      <li>item 2</li>
      <li>item 3</li>
      <li>item 4</li>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 491k
  • Answers 491k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The pagination plugin actually does have this built-in, it's just… May 16, 2026 at 10:03 am
  • Editorial Team
    Editorial Team added an answer You need to create a library project and reference it… May 16, 2026 at 10:03 am
  • Editorial Team
    Editorial Team added an answer declare your "a" global to store its value. Because your… May 16, 2026 at 10:03 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to create an abstract class, defining an abstract method, that is to
Does NSLog() have variants that print without the time and date stamps, and the
I have a JSP page that renders a block of HTML. In normal usage,
Is there a dialect of XML for defining the tables, indexes and relations of
It seems that if I want to create a very basic Cocoa application with
I have to define a web service contract that afterwards will be used by
I have a class that extends the HtmlHelper in MVC and allows me to
In HTML forms, buttons can be disabled by defining the disabled attribute on them,
I am finishing up an app for a client that uses in app purchases
A set of APIs that I commonly use follow a linked-list pattern: struct SomeObject

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.