How to Center the Navigation Menu in Twenty Sixteen Theme
Content
A common challenge for users of the Twenty Sixteen theme is centering the primary navigation menu. The theme's default layout aligns the menu to the right, which may not suit every website's design. Based on numerous community discussions, this guide will explain why this happens and provide the most effective solutions.
Why is the Menu Not Centered by Default?
The Twenty Sixteen theme uses a flexbox layout for its header elements. This modern CSS technique is great for responsive design but can make traditional centering methods, like text-align: center, ineffective. The menu's alignment is controlled by the flex container properties in the .site-header-main class.
Most Effective Solution: Using CSS Media Queries
The most widely reported and successful method for centering the menu involves overriding the flex properties and applying auto margins. This solution should be added to your site's Additional CSS section (Appearance > Customize > Additional CSS) or to your child theme's stylesheet.
@media screen and (min-width: 44.375em) {
.site-header-main .site-branding {
margin: 0;
}
.site-header-menu {
margin: 0 auto;
}
.primary-menu {
justify-content: center;
}
}
How it works:
@media screen and (min-width: 44.375em): This targets only desktop-sized screens, preventing issues with the mobile menu..site-header-main .site-branding { margin: 0; }: Removes the default margin from the site branding (title/logo)..site-header-menu { margin: 0 auto; }: Centers the menu container itself..primary-menu { justify-content: center; }: Centers the menu items within the container.
Alternative Method: Adjusting Flex Properties
If the above code doesn't achieve the desired result, another approach is to modify the flex properties directly. Some users found success by removing the display: -webkit-flex; declaration.
@media screen and (min-width: 44.375em) {
.site-header-main {
display: block; /* Changes from flex to block */
}
.site-header-menu {
margin: 0 auto;
text-align: center;
}
.main-navigation li {
display: inline-block; /* Changes list items to inline-block */
float: none;
}
}
Important Considerations
- Child Theme: Always use a child theme when making modifications. This prevents your changes from being overwritten during theme updates.
- Browser Testing: After applying any CSS, test your site on different browsers and devices to ensure the menu behaves correctly, especially when switching to the mobile "hamburger" view.
- Specificity: If other CSS rules are conflicting, you may need to use more specific selectors or the
!importantrule (use sparingly).
These solutions, compiled from successful community reports, provide a reliable starting point for centering your Twenty Sixteen navigation menu. If one method doesn't work perfectly for your specific setup, try adjusting the values or combining approaches.
Related Support Threads Support
-
How to center main menuhttps://wordpress.org/support/topic/how-to-center-main-menu-2/
-
Make menu items take full width from left to righthttps://wordpress.org/support/topic/make-menu-items-take-full-width-from-left-to-right/
-
Adding a menu to top of 2016 themehttps://wordpress.org/support/topic/adding-a-menu-to-top-of-2016-theme/
-
Add icons to menu, front of item titlehttps://wordpress.org/support/topic/add-icons-to-menu-front-of-item-title/
-
Wrap menu itemshttps://wordpress.org/support/topic/wrap-menu-items/
-
Move primary menu below header, make header area full widthhttps://wordpress.org/support/topic/move-primary-menu-below-header-make-header-area-full-width/
-
Would like to center nav barhttps://wordpress.org/support/topic/would-like-to-center-nav-bar/
-
move menu and right column of bloghttps://wordpress.org/support/topic/move-menu-and-right-column-of-blog-2/
-
Edit ONE Menu Itemhttps://wordpress.org/support/topic/edit-one-menu-item/
-
center navbar, move header image to top, hide post tags…https://wordpress.org/support/topic/center-navbar-move-header-image-to-top-hide-post-tags/
-
How can i change back ground color custom menu(custom menu widget)https://wordpress.org/support/topic/how-can-i-change-back-ground-color-custom-menucustom-menu-widget/
-
Navigation menu parent item colourhttps://wordpress.org/support/topic/navigation-menu-parent-item-colour/
-
Main nav menu widehttps://wordpress.org/support/topic/main-nav-menu-wide/
-
Changing the look of Menu Linkshttps://wordpress.org/support/topic/changing-the-look-of-menu-links/
-
Cannot centre nav menu (above header)https://wordpress.org/support/topic/cannot-centre-nav-menu-above-header/
-
Social Links Menuhttps://wordpress.org/support/topic/social-links-menu-2/
-
how to arrange differnt menu blocks – (see an example)https://wordpress.org/support/topic/how-to-arrange-differnt-menu-blocks-see-an-example/
-
position nav menu in a toolbar at top of pagehttps://wordpress.org/support/topic/position-nav-menu-in-a-toolbar-at-top-of-page/
-
Nav menu links in new windowhttps://wordpress.org/support/topic/nav-menu-links-in-new-window/
-
menu & menu buttonhttps://wordpress.org/support/topic/menu-menu-button/
-
Centre align new menu areahttps://wordpress.org/support/topic/centre-align-new-menu-area/
-
Menu in wrong place (Under Header instead on on top righthttps://wordpress.org/support/topic/menu-in-wrong-place-under-header-instead-on-on-top-right/
-
Postion of Menu/Hamburger on Home Pagehttps://wordpress.org/support/topic/postion-of-menuhamburger-on-home-page/
-
center menu twenty sixteenhttps://wordpress.org/support/topic/center-menu-twenty-sixteen-1/
-
Menu button repositioninghttps://wordpress.org/support/topic/menu-button-repositioning/
-
Does Social Menu Allow for Multiple Facebook Links?https://wordpress.org/support/topic/does-social-menu-allow-for-multiple-facebook-links/
-
Can "primary" and "social" be translated?https://wordpress.org/support/topic/can-primary-and-social-be-translated/
-
Scroll over sub menu, main menu color?https://wordpress.org/support/topic/scroll-over-sub-menu-main-menu-color/
-
How to float main navigation menu to left?https://wordpress.org/support/topic/how-to-float-main-navigation-menu-to-left/
-
Menu now centered. But how to center menu items?https://wordpress.org/support/topic/menu-now-centered-but-how-to-center-menu-items/
-
Centre justifying in theme Twenty Sixteenhttps://wordpress.org/support/topic/centre-justifying-in-theme-twenty-sixteen/
-
Move top nav menu to left ?https://wordpress.org/support/topic/move-top-nav-menu-to-left/
-
Alignment issuehttps://wordpress.org/support/topic/alignment-issue-28/
-
Add search bar to main navigation menuhttps://wordpress.org/support/topic/add-search-bar-to-top-menu/
-
Any advice on making nav bar flush with header?https://wordpress.org/support/topic/any-advice-on-making-nav-bar-flush-with-header/
-
Help – Removing Main Navigation Menu From Single Page (Not Homepage)https://wordpress.org/support/topic/help-removing-main-navigation-menu-from-single-page-not-homepage/
-
SIte Title and Menu placementhttps://wordpress.org/support/topic/site-title-and-menu-placement/
-
Center Align Twenty Sixteen Menuhttps://wordpress.org/support/topic/center-align-twenty-sixteen-menu/
-
How to make the third level menu right side instead of left?https://wordpress.org/support/topic/how-to-make-the-third-level-menu-right-side-instead-of-left/
-
Target nav menu active link (span) with bottom borderhttps://wordpress.org/support/topic/target-nav-menu-active-link-span-with-bottom-border/
-
Menu Button right alignedhttps://wordpress.org/support/topic/menu-button-right-aligned/
-
Install sticky Burger Menu with Logo optionhttps://wordpress.org/support/topic/install-stickx-burger-menu-with-logo-option/
-
Add BuddyPress Pages to menuhttps://wordpress.org/support/topic/add-buddypress-pages-to-menu/