Taming Shopify's Tricky Spacing: How to Get Your Headers and Content Just Right
Hey store owners! Ever found yourself staring at your Shopify pages, wondering why there's just *so much* space between your page title and the actual content? You set the padding to zero, but that stubborn gap persists, making your beautiful design look… well, a little off? You’re not alone. This is a super common head-scratcher, and it came up recently in the Shopify Community forums when a store owner, creativebp8, asked for help with their Brand and News pages.
They’d already tried adjusting padding, but the spacing still looked “abnormal” and “bigger” than other sections. This is a classic example of how seemingly simple design tweaks can get complicated fast in Shopify. The good news? Our community experts jumped in with some fantastic insights and solutions. Let's break down why this happens and how you can get your page layouts looking perfectly balanced.
Why That Space Just Won't Go Away
The core of the problem, as our community expert rajweb pointed out, is that the spacing isn't usually coming from just one place. It's often a combination of several elements:
- The main page container's top padding.
- Default margin-bottom on your page titles (which are usually H1 elements).
- Additional spacing from the rich text wrapper or content containers.
It's like trying to close a door that has multiple hinges – you need to address each one! So, let's look at the different approaches shared by the community.
First Stop: Your Theme Section Settings
Before diving into code, always check the easiest route. DitalTek, another helpful community member, reminded us that sometimes the solution is right there in your theme editor. Many modern Shopify themes offer built-in spacing controls within the section settings themselves.
Here’s how to check:
- Go to your Shopify Admin.
- Navigate to Online Store > Themes.
- Click Customize on your current theme.
- On the left sidebar, navigate to the specific page or section you want to adjust (e.g., your “Brand” page).
- Click on the relevant section (e.g., a “Rich text” section or “Page” section).
- Look for settings related to Padding, Margin, or Spacing, usually under a “Layout” or “Section Spacing” heading.
DitalTek even shared an image showing where these settings might be:
If you can adjust it here, fantastic! If not, it's time to roll up our sleeves a bit more.
Diving Deeper: Custom CSS Solutions
When theme settings aren't enough, CSS is your best friend. Several community members offered specific CSS snippets, and it's important to understand where to put them for the best effect.
Targeting the Page Title (H1) Margin
Often, the biggest culprit is the default `margin-bottom` on your page title (which is usually an element with a class like .main-page-title). Tim_1 suggested a very clean solution for this:
Tim_1 noted that even if you set section padding to 0, you need to check internal elements. For the H1 element, he recommended this code:
h1.main-page-title {
margin-bottom: 0;
}
You can often add this directly into the “Custom CSS” section of the specific page template or section you're working on in the theme editor. This keeps the change localized. Rajat and DitalTek also highlighted adjusting the `margin-bottom` for the main page title.
Here's a visual from Tim_1 showing the difference this can make:
Notice how much tighter the content becomes to the title after the CSS is applied.
Adjusting Rich Text and Main Content Areas
Sometimes the issue isn't just the title, but the content area itself. Rajweb and Tim_1 provided solutions for this:
-
For the Rich Text section: Tim_1 suggested this to reduce top padding:
.rich-text.content-container { padding-top: 0.5rem; } -
For the overall page container and rich text: Rajweb offered a more comprehensive set of rules:
.template-page .page-width { padding-top: 0 !important; } .template-page .rte { margin-top: 0 !important; padding-top: 0 !important; } main#MainContent { padding-top: 0 !important; }
These snippets target various elements that might be adding default spacing. You can add these to your theme's `base.css` or `theme.css` file (Online Store > Themes > Edit code > Assets > `base.css` or `theme.css`) at the very bottom.
A Simpler Global `theme.liquid` Option
Moeed, one of the first responders in the thread, offered a quick way to adjust the top padding for the desktop page width. This is a good general approach if you want to tighten up the overall page content area:
To implement this:
- Go to Online Store > Themes.
- Click Actions > Edit Code.
- Find the
theme.liquidfile. - Add the following code at the bottom of the file, just above the



