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 8411301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:23:46+00:00 2026-06-10T00:23:46+00:00

In this question, I am not going to ask How to horizontally center an

  • 0

In this question, I am not going to ask “How” to horizontally center an unordered list, because there are about eleventy thousand resources already on the internet for that.

Instead, I’d liked to ask the “WHY” part of it.

More precisely, why do we do this

ul {
   position:relative;
   left:50%;
}
ul > li {
   position:relative;
   right: 50%;
}

instead of this:

ul {
   position:relative;
   left:25%;
}

When both seem to do the trick.
Any thoughts?

  • 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-06-10T00:23:47+00:00Added an answer on June 10, 2026 at 12:23 am

    The reason is, because the first method centers the ul in every case – indepentend on how many child li it has.

    The second solution places the ul 25% to the right which will work in a very special case, when the widht of the li is just right to occupy 50% of the total width but breaks in any other case.

    using left on the parent and right on the child is a very common practice to center a child with dynamic dimensions(width) which is the case when dealing with dynamic content.

    In some cases, text-align:center; works too, but fails when you have to use absolute positioning.

    See an example fiddle here.

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

Sidebar

Related Questions

I hope that this one is not going to be ask-and-answer question... here goes:
I'm going to preface with: I hope I can ask this question here, because
I was going to ask a question here about whether or not my design
I was asked to repost this question, due to the answers were not going
This question is not technical, but is still about programming. What is the funniest,
This question is not about caching. I need this in-memory table for many small
This question is not about which is the best, it is about which makes
This question is not about 'best' barcode library recommendation, we use various products on
I'm going to re-ask this question in a slightly different way. Say I have
I'm not sure how to even ask this question. We are running SQL Server

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.