0

As specified in the answer of difference between width auto and width 100 percent the width auto takes full width but in this demo the width auto doesn't take the full width but when we apply 100% to this then only it takes full width. How the width auto takes its element actually?

Demo summary

html

<ul>
    <li>one</li>
    <li>two</li>
    <li>three</li>
</ul>

css

ul{background-color: gray;}
li{background-color: red; float: left; clear: left; width: auto;}
Community
  • 1
  • 1
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231

2 Answers2

0

try this

http://jsfiddle.net/p5bQP/1/

CSS

ul{
  background-color: gray; 
  float:left;
  }
li{
  background-color: red; 
  float: left; 
  clear: left; 
  width:100%;
  }
Falguni Panchal
  • 8,873
  • 3
  • 27
  • 33
0

The problem ist the floating on the li element.

If you remove the floating part from your css like that:

ul{background-color: gray;}
li{background-color: red; width: auto;}

then it works fine.

mordilion
  • 33
  • 1