tags:

views:

124

answers:

3

I have a code like this:

<table>
<tr>
<td align="center">
<ul>
<li style="float:left;display:inline">Some text</li>
<li style="float:left;display:inline">Other text</li>
</ul>
</td>
</tr>
</table>

The problem is that the UL with is 100% and then all UL is aligned to the left, how can i center the content into UL? I must have that style for the LI, so i need that UL with fits to his content... does anyone knows how to do this?

regards,

A: 

You could try to apply display:inline to the ul instead of the li.

What is the reason you're applying it to the li anyway? It seems unnecessary because they are floated, but perhaps there is another reason.

jeroen
+1  A: 

A margin:auto style on the <table> should work. And you don't need align="center" on the <td>. Try this:

<table style="margin:auto">
    <tr>
        <td>
            <ul>
                <li style="float:left;display:inline">Some text</li>
                <li style="float:left;display:inline">Other text</li>
            </ul>
        </td>
    </tr>
</table>
Asaph
+1  A: 

Hi fidoboy,

Just remove that "float:left" from your li code because "display:inline" is itself do that job for you which you want with "float:left".

Bhupi
The LI tag also have a image background and the only way to get this background working is using float:left;
fidoboy
U mean, without using "float:left" the background images can not be displayed in "li"?To the best of my knowledge, it works fine without using floats also. And in your requirement, if u don't remove that "float:left", then I think it can't be achieved.
Bhupi