Css centering links inside a div

Hey, how can I focus my links like that? They are all centered inside a div, but they start at the same distance.

i am link 1
i am a longer link than link 1
i am a short link
we are all centered in div

If I applied text align: center, I get:

         i am link 1
i am a longer link than link 1
      i am a short link
   we are all centered in div

Thank;)

I have a table

{anchor}

links should be focused on my path, each in its own td. Not sure maybe

+5
source share
4 answers

Wrap links in another <div style="width: 300px; margin: 0 auto;">to group them.

http://jsfiddle.net/NcEpe/1/

Edit for dynamic width: http://matthewjamestaylor.com/blog/beautiful-css-centered-menus-no-hacks-full-cross-browser-support

+6
source

, inline-block , . text-align:center; .

, IE, , , .

+20

Try text-align: left;

0
source

Do this: insert the left-aligned div into the center-aligned div.

<div style="text-align:center">
    <div style="text-align:left; width:300px;">
        Content<br />
        Longer Content<br />
        Really long Content<br />
        Content<br />
        Content
    </div>
</div>

Addition:

CSS lovers everywhere will blame me for replacing the inner div with a table that eliminates the need for a fixed (or percentage) width.

0
source

All Articles