Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7487813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:39:45+00:00 2026-05-29T14:39:45+00:00

Say you have a horizontal, graphical nav menu where each menu item is variable

  • 0

Say you have a horizontal, graphical nav menu where each menu item is variable width (controlled by padding rather than a width to the <li> element). This means you can’t truly know the width of the ul (in order to center it) because the text is different sizes in different browsers.

Up until now I would either

A) Just eye it and use margin-left on the ul

B) use jquery to calculate the width and then set set it as an inline-style so that the width can be set, and then it can be margin: auto’d.

But someone just told me I can use display: inline and it works fine, without using float, and it always centers? has anyone heard of this? he’s kind of new and can’t quite explain it so i’m curious what you guys think. He says he thinks text-align: center. I dont see how this would work on a menu though.. which is not text?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T14:39:46+00:00Added an answer on May 29, 2026 at 2:39 pm

    Any text level element can be centred. It’ll be centered according to its parent element. Which should be a block level element.

    The following menu can be centred,

    <ul id="ul">
    <li>one</li>
    <li>two</li>
    <li>January</li>
    <li>September</li>
    </ul>
    

    Using this CSS

    ul#ul{text-align:center;}
    ul#ul li{display:inline;}
    

    See this jsfiddle to get an idea

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a horizontal <ul> menu. How can I fix the width of the
Say I have a window, where there are 2 horizontal sppliters, and a button.
Let's say I have a simple TextBox next to a Label: <StackPanel> <StackPanel Orientation=Horizontal>
Let's say I have a simple chunck of XML:- <root> <item forename=Fred surname=Flintstone />
Say I have 2 buttons in an Element and I want to set the
Hope someone can have a look and say why there's a horizontal gap on
I have a horizontal css menu with 5 items. e.g 1) Home 2) Users
OK. I have a horizontal image, let's say 2000 x 300. I want to
I have a linear layout (horizontal) inside which there is 3 linear layouts, each
I have a two pages say Main.xaml and Details.xaml .Each page has a ListBox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.