How to Reduce Header and Content Spacing in the Twenty Twenty Theme
Content
A common challenge for users of the Twenty Twenty theme is managing the default spacing, particularly the large gaps below the site header and above page content. This extensive white space, while a design feature, often pushes valuable content down the page. Based on community discussions, this guide outlines the most effective methods to control this spacing using custom CSS.
Why Does This Spacing Happen?
The Twenty Twenty theme is designed with a focus on readability and a spacious, modern aesthetic. This is achieved through default CSS properties like padding and margin on key elements such as the header, cover block, and post content containers. While this looks great on some sites, many users find they need a more compact layout.
Common Solutions to Reduce Spacing
1. Reducing the Main Site Header Padding
To shrink the white space inside your main header area, target the .header-inner class. The default padding is quite large, so reducing it can have a significant impact.
.header-inner {
padding: 1rem 0; /* Adjust this value as needed */
}
2. Adjusting the Cover Template Height
Many users want to reduce the full-screen height of the Cover Template. The following CSS changes the container height and repositions the inner content to keep it visible.
.cover-header {
max-height: 70vh !important; /* Adjust the viewport height percentage */
}
.cover-header-inner {
padding: 0 0 40vh 0 !important; /* Adjust to match the new height */
}
3. Removing Space Below the Header on Standard Pages
If you have a large gap between your header and the start of your page's content, the issue is often the padding on the .post-inner element. This is especially common on homepages where the title has been hidden.
.post-inner {
padding-top: 0 !important;
}
Note: To target only the homepage, you can use a more specific selector like .home .post-inner.
4. Fine-Tuning Block and Heading Margins
To adjust the space after a specific heading (e.g., an H5) or other block, you can target its bottom margin directly.
.entry-content h5 {
margin-bottom: 5px; /* Adjust this value */
}
How to Add This CSS
- Navigate to your WordPress Dashboard.
- Go to Appearance > Customize.
- Click on Additional CSS.
- Paste your chosen CSS code into the text box.
- Click Publish to save your changes.
Important Considerations
- Use !important Sparingly: The
!importantrule is sometimes necessary to override strong default styles, but it can make future CSS changes difficult. Use it only if your changes don't apply without it. - Test on Mobile: Always check how your spacing changes look on mobile devices. You may need to add mobile-specific CSS using
@mediaqueries to ensure a good responsive experience. - Consider a Child Theme: For more extensive modifications, creating a child theme is the recommended best practice. This protects your changes from being overwritten when the theme is updated.
By using these targeted CSS snippets, you can effectively take control of the layout in the Twenty Twenty theme and create a design that better suits your content.
Related Support Threads Support
-
Password protected page formhttps://wordpress.org/support/topic/password-protected-page-form-2/
-
Large space between heading and table…https://wordpress.org/support/topic/large-space-between-heading-and-table/
-
Header Screen Estatehttps://wordpress.org/support/topic/header-screen-estate/
-
Heading Cut Off When Browser Is Minimisehttps://wordpress.org/support/topic/heading-cut-off-when-browser-is-minimise-2/
-
Twenty twenty cover template page space tophttps://wordpress.org/support/topic/twenty-twenty-cover-template-page-space-top/
-
Remove, adjust and Edithttps://wordpress.org/support/topic/remove-adjust-and-edit/
-
Bar of Background color between header and cover photohttps://wordpress.org/support/topic/bar-of-background-color-between-header-and-cover-photo/
-
Top padding of body disappearedhttps://wordpress.org/support/topic/top-padding-of-body-disappeared/
-
How to change header height?https://wordpress.org/support/topic/how-to-change-header-height-2/
-
Remove padding under headinghttps://wordpress.org/support/topic/remove-padding-under-heading/
-
space between header and picturehttps://wordpress.org/support/topic/space-between-header-and-picture/
-
Reduce Cover Template header heighthttps://wordpress.org/support/topic/reduce-cover-template-header-height/
-
twenty twenty; reduce the distance between the top line and the first headinghttps://wordpress.org/support/topic/twenty-twenty-reduce-the-distance-between-the-top-line-and-the-first-heading/
-
theme twenty twenty – adjusting margin/padding. and removing built in block.https://wordpress.org/support/topic/theme-twenty-twenty-adjusting-margin-padding-and-removing-built-in-block/
-
Custom Page Header size Decreasehttps://wordpress.org/support/topic/custom-page-header-size-decrease/
-
Decreasing padding help neededhttps://wordpress.org/support/topic/decreasing-padding-help-needed/
-
Thin line of colour along edge of front page headline imagehttps://wordpress.org/support/topic/thin-line-of-colour-along-edge-of-front-page-headline-image/
-
Gallery top and bottom spacinghttps://wordpress.org/support/topic/gallery-top-and-bottom-spacing/
-
Disable parallax on portrait viewshttps://wordpress.org/support/topic/disable-parallax-on-portrait-views/
-
Header Size – How to Reduce with a Sliderhttps://wordpress.org/support/topic/header-size-how-to-reduce-with-a-slider/
-
h5 margin-bottom is too bighttps://wordpress.org/support/topic/h5-margin-bottom-is-too-big/
-
Decreasing padding before and after ulhttps://wordpress.org/support/topic/decreasing-padding-before-and-after-ul/
-
making the first block attach to the header on homepagehttps://wordpress.org/support/topic/making-the-first-block-attach-to-the-header-on-homepage/
-
Captions are spaced too far under tableshttps://wordpress.org/support/topic/captions-are-spaced-too-far-under-tables/
-
Header too largehttps://wordpress.org/support/topic/header-too-large/
-
Remove top padding. Make first block on homepage flush against the header menuhttps://wordpress.org/support/topic/remove-top-padding-make-first-block-on-homepage-flush-against-the-header-menu/
-
Reducing block padding . Which css class?https://wordpress.org/support/topic/reducing-block-padding-which-css-class/
-
Reduce the Height of the Main Headerhttps://wordpress.org/support/topic/reduce-the-height-of-the-main-header/
-
Hight of the headerhttps://wordpress.org/support/topic/hight-of-the-header/
-
smaller the header sizehttps://wordpress.org/support/topic/smaller-the-header-size/
-
targeting a section to decrease padding/marginhttps://wordpress.org/support/topic/targeting-a-section-to-decrease-padding-margin/
-
Reducing Theme Cover Image Heighthttps://wordpress.org/support/topic/reducing-theme-cover-image-height/