Search code examples
htmlcssalignment

div align center then left without using width


I have div's inside a div

<div id="out" align="center">
      <div id="in1" align="left">111</div>
      <div id="in2" align="left">aaaaaaaaaaaaaaaaaaaaaa</div>
      <div id="in3" align="left">bbbb</div>
      <div id="in4" align="left">6516519191</div>
      <div id="in5" align="left">apple</div>
      <div id="in6" align="left">ii</div>
</div>

The expected result is a div with size=(max inside div size) which is centered. Then items inside it are all aligned left:

                         111
                         aaaaaaaaaaaaaaaaaaaaaa
                         bbbb
                         6516519191
                         apple
                         ii

I don't want to give width to the outer div since I have no idea about size of the items from before.

is there any way?


Solution

  • First, there is no "align" attribute for div's.

    The information you are providing looks like tabular data. In that case, a table should be used, not div's.