How to center a Menu in Wordpress with style.css

I have this piece of code in style.css

ul#secondary-menu {
    padding-left: 18px;

how do I align this to be centered in page?

The page I am talking about is located here:


Add this to your id in CSS

    ul#secondary-menu { 
    padding-left: 18px; 
    margin: auto;
    width: 300px;

The width will define the width of the menu of course but the margin auto will align it in the center to its parent.

Given that it is a sub-menu you dont need to have it width 960px, just have the width the width of the content.


Tags: Css / Wordpress

Similar questions

why does my 'style.css' file become 'style.css?ver=4.1.1'?
I am using wordpress and I've made a theme child folder with style.css in it. I've done a little work to it and saved it, but the problem is, only that first save of style.css is being activated. I've added more code into style.css but my new code is not being applied. In the inspect element, it's loading up "style.css?ver=4.1.1" and not "style.css...
Child style.css not overwriting parent style.css
I realise this has been asked before, but none of the previous questions help. This is my function Both stylesheets load, but none of the rules of the child styles.css show up when I inspect.
CSS Aligning Sub Menu Center Wordpress
So basically I need to produce a menu like this in Wordpress: Where the red bar is the width of the page and not fixed so can shrink with resize. And the submenu is centred I currently have: And the CSS is: Any help
Align Header Menu in the center: Wordpress (Avada Theme) Custom CSS
On my website ( I'd like to have the top header menu in the center, at the moment it is on the right. (I will also remove the logo, so that only the text is in the center). However there is no selection from the Avada theme to put it in the center. First, I was trying to look in the Avada forum for a specific Custom CSS code that I ...
How do you center the main menu in CSS?
Do any of you know of a way to center the main menu on my company's site? I have been trying all day and am frazzled! I've tried editing the stylesheet but nothing has fixed it. I've tried throwing white-space: nowrap around in the CSS but it had no effect regardless of where I put it. Ahh! We're using the Meta-Morphosis theme if that is any help. ...
Trying to center this submenu in this css menu
Looking for some CSS help, if there is some kind soul out there :) I have made a little CSS button menu bar to go above my Wordpress posts. The first bar has dropdowns for regions, which contain countries. The first two have only one entry, so they are centred below the button which looks ok. The second two have multiple entries and are not centred...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.