Centering li, when commented

hi folks,
i am trying achieve something. i have this li with inline style. what i want is suppose i have this code


and css for ul as

li{display inline;}

now after i did that, suppose i comment out the li for gallery. this forces the right next to li to slide back. what i am looking for is even when any li is commented out (from any direction or center), the other remaining li’s land in center of screen. is it achievable via css ?

Don’t you need to apply the same styling when an item hasn’t been commented out, though? The links you’ve got are not usually going to fill the full width of the container - and even if they are on your screen, you can’t rely on them doing so for everyone else!

Try adding text alignment…

ul{width:800px; text-align: center;}

nope i don’t want the space reserved, what i need is when a element is commented out. the remaining should be centered, equal from both sides, so it look like the only displayed listed items are all there is and are centered without a person knowing that a element has been hidden.
in short i need to fill in space when some middle li is commented out

If you want an element to be hidden from view, but to have its space reserved on the page, give it a style of “visibility:hidden;”.

I would do Bluedreamer’s text-align: center, because then it should center within that 800px-wide ul (and you maybe want to center that ul too… with automargins). So long as the li’s remain inline (or inline-block) they’ll center themselves if the ul says text-align: center.

ul {
width: 800px;
margin: 0 auto;
text-align: center; /*remember this only affects inline or inline-block children */
li {
display: inline;

remember too that inline’s can’t do some things blocks can, and normally li’s are blocks… your li’s won’t be able to have vertical margins, won’t be able to have set dimensions (height, width) etc…