How to Reduce or Remove Unwanted White Space in Twenty Twenty-One
Content
One of the most common questions from users of the Twenty Twenty-One theme is how to manage the large amounts of white space that can appear around headers, between blocks, and above the footer. This space is a core part of the theme's modern, spacious design, but it's not always suitable for every website. This guide will explain why this space exists and provide the most effective CSS solutions to control it.
Why is There So Much White Space?
The Twenty Twenty-One theme uses a design system based on CSS variables for consistent spacing. The primary variable controlling vertical space is --global--spacing-vertical, which is set to 30px. This variable is used to calculate padding and margins for many elements, including the header, content areas, and footer. This creates a clean, airy layout but can sometimes result in more space than desired.
Common Solutions for Reducing White Space
The following CSS snippets can be added to your site via the Appearance → Customize → Additional CSS panel in your WordPress dashboard. This is the recommended method, as it ensures your changes are not lost when the theme is updated.
1. Reducing Space Above the Footer
This is perhaps the most frequent request. A large gap between your page content and the footer is often caused by the widget area margin. To reduce it, use the following CSS:
.widget-area {
margin-top: 10px;
}
You can adjust the 10px value to your liking. For a more drastic reduction, this combination has proven effective for many users:
.no-widgets .site-footer {
margin-top: 0;
}
nav.footer-navigation {
margin-top: 0;
}
2. Reducing Space Below the Header/Menu
To remove the pronounced gap between your menu and the page content, target the site content's padding.
.site-content {
padding-top: 0;
}
3. Reducing Space Between Blocks
To tighten the default spacing between Gutenberg blocks (like paragraphs and headings), you will need to adjust the block gap.
.entry-content > * {
margin-top: 20px;
margin-bottom: 20px;
}
Adjust the 20px values to achieve your desired spacing.
4. Removing the Horizontal Line in the Footer
If you have a dark background, the white footer separator line might be undesirable. It can be removed with this code:
.site-footer > .sep {
display: none;
}
Important Notes and Troubleshooting
- Specificity: Sometimes, your custom CSS might not override the theme's default styles. If a change isn't working, try adding
!importantto the rule (e.g.,margin-top: 0 !important;). Use this sparingly. - Browser Inspector is Your Best Tool: To find the exact element causing space on your specific site, right-click on the area and select "Inspect" or "Inspect Element." This will show you the HTML structure and the CSS rules applying to it, allowing you to identify the correct class to target.
- Mobile vs. Desktop: The theme uses responsive CSS. A change that works on desktop may not work on mobile, or vice versa. Use the browser inspector to test how your site looks on different screen sizes.
- The "Edit" Link: If you see an "Edit" link and a large space at the bottom of a page, note that this link is only visible to logged-in administrators. Regular visitors cannot see it, so you typically do not need to remove it.
By using these targeted CSS solutions, you can fine-tune the layout of your Twenty Twenty-One theme to perfectly match your design vision without altering the core theme files.
Related Support Threads Support
-
Reducing vertical space between blockshttps://wordpress.org/support/topic/reducing-vertical-space-between-blocks/
-
Remove 30px top marginhttps://wordpress.org/support/topic/remove-30px-top-margin/
-
Excess space at bottom of page bodyhttps://wordpress.org/support/topic/excess-space-at-bottom-of-page-body/
-
Remove Empty Spacehttps://wordpress.org/support/topic/remove-empty-space-4/
-
How to remove extra space between blocks?https://wordpress.org/support/topic/how-to-remove-extra-space-between-blocks/
-
Remove excess space under menu barhttps://wordpress.org/support/topic/remove-excess-space-under-menu-bar/
-
How to remove the footer horizontal linehttps://wordpress.org/support/topic/how-to-remove-the-footer-horizontal-line/
-
Posts have big space after header on mobilehttps://wordpress.org/support/topic/posts-have-big-space-after-header-on-mobile/
-
Reduce empty spacehttps://wordpress.org/support/topic/reduce-empty-space/
-
Remove blank space above footerhttps://wordpress.org/support/topic/remove-blank-space-above-footer/
-
the end of the page has a blank spacehttps://wordpress.org/support/topic/the-end-of-the-page-has-a-blank-space/
-
Remove blank space between content and footerhttps://wordpress.org/support/topic/remove-blank-space-between-content-and-footer/
-
“Edit” link with BIG space at bottom of home pagehttps://wordpress.org/support/topic/edit-link-with-big-space-at-bottom-of-home-page/
-
Remove large box near bottom of page?https://wordpress.org/support/topic/remove-large-box-near-bottom-of-page/
-
Gap between blockshttps://wordpress.org/support/topic/gap-between-blocks-2/
-
Gap below mastheadhttps://wordpress.org/support/topic/gap-below-masthead/
-
white space between footer and page contenthttps://wordpress.org/support/topic/white-space-between-footer-and-page-content/
-
Removing “NOTHING HERE”https://wordpress.org/support/topic/removing-nothing-here/
-
how to reduce space between content and footerhttps://wordpress.org/support/topic/how-to-reduce-space-between-content-and-footer/
-
white spacehttps://wordpress.org/support/topic/white-space-53/
-
white spacehttps://wordpress.org/support/topic/white-space-52/
-
Remove line under headerhttps://wordpress.org/support/topic/remove-line-under-header/
-
Footer texthttps://wordpress.org/support/topic/footer-text-26/
-
Unwanted Blank Space to the Righthttps://wordpress.org/support/topic/unwanted-blank-space-to-the-right/
-
Space between the title and the entry contenthttps://wordpress.org/support/topic/space-between-the-title-and-the-entry-content/
-
remove white borderhttps://wordpress.org/support/topic/remove-white-border-2/
-
Remove margin on sectionhttps://wordpress.org/support/topic/remove-margin-on-section/
-
eliminate spacing between blockshttps://wordpress.org/support/topic/eliminate-spacing-between-blocks/
-
Hide entry-footerhttps://wordpress.org/support/topic/hide-entry-footer/
-
Remove Whitespacehttps://wordpress.org/support/topic/remove-whitespace-3/