Mastering Your Horizon Theme Header: Centering, Spacing & Dividers with CSS

Hey there, fellow store owners! Navigating the world of Shopify themes can sometimes feel like a treasure hunt, especially when you're trying to get your store's design just right. We all want that polished, professional look, and the header is often the first thing a customer sees. So, when Pilotwolf recently reached out to the community about customizing their Horizon theme header, it really resonated with a lot of us.

Pilotwolf was aiming for a specific header style: clean margins on the left and right, and clear dividers between elements. They'd tried a bunch of CSS options, even managed to move icons around, but those elusive margins and dividers were proving tricky. It's a classic scenario, right? You know what you want, you're trying to use CSS, but the theme just isn't behaving.

Understanding the Horizon Header Challenge

Before diving into solutions, it’s super helpful to understand why this can be a bit of a head-scratcher with modern themes like Horizon. As our community expert gracetech1 wisely pointed out, many contemporary Shopify themes rely heavily on CSS Flexbox, Grid, and CSS variables for their layout and spacing. This means that simply adding a margin property might not always give you the desired effect, especially if a parent container is set to be full-width or has its spacing controlled by these more advanced methods.

Gracetech1 also highlighted that those clean dividers we often see aren't always simple border properties. Sometimes, they're created using CSS pseudo-elements (like ::before or ::after), which means you need to target them specifically if you want to modify or replace them. Pilotwolf even mentioned struggling with “conflicting divider layers,” which perfectly illustrates this point. It's not just about adding a new border; it's often about overriding or removing existing, hidden ones.

The Community's Step-by-Step Solution for a Polished Header

Thankfully, the community rallied, and Wsp provided a fantastic, comprehensive CSS solution that tackles these exact issues. This approach aims to give you a properly centered, boxed header with balanced spacing and a single, clean divider. Remember, before you make any code changes, it's always a good idea to duplicate your theme first! That way, you've got a safe rollback point.

You'll typically add this CSS to your theme's base.css file (or theme.css, depending on your theme version). Go to Online Store > Themes > Actions > Edit code, then navigate to your Assets folder and find base.css or theme.css. Paste the following snippets at the very bottom of the file.

1. Add Proper Header Container Spacing

First, we need to ensure your header content isn't stretching edge-to-edge. This CSS sets a maximum width for the inner header elements and centers them, adding a bit of padding on the sides for breathing room.

header .header__inner,
header .header__content,
header .page-width {
max-width: 1200px;
margin: 0 auto;
padding-left: 24px;
padding-right: 24px;
}

2. Fix Alignment (Logo / Menu / Icons)

To ensure your logo, menu, and icons are perfectly aligned and spaced out within that new container, we'll use Flexbox on the header__inner element. This makes sure everything is nicely distributed.

header .header__inner {
display: flex;
justify-content: space-between;
align-items: center;
}

3. Remove Conflicting Divider Layers

This is where we address those tricky, hidden dividers gracetech1 mentioned. Horizon often uses multiple layers or pseudo-elements for its borders, which can make things messy. This code snippet effectively hides them all, giving us a clean slate.

header::before,
header::after,
header .header__inner::before,
header .header__inner::after {
display: none !important;
}

4. Add One Clean Divider

Now that the old dividers are gone, we can add a single, crisp border at the bottom of your header. Wsp offered two options here; try the first one, and if it doesn't quite look right, switch to the second:

Option A: Border on the main header element

header {
border-bottom: 1px solid #e5e5e5;
}

Option B: Border on the inner header container (if Option A doesn't show correctly)

header .header__inner {
border-bottom: 1px solid #e5e5e5;
}

5. If Spacing Still Looks Full-Width

Sometimes, Horizon can be stubborn about its full-width container. If you find that the header is still stretching despite the max-width you applied earlier, add this:

header {
width: 100%;
}

Wsp notes that after these changes, your header should be beautifully centered in a boxed layout, with balanced spacing and perfectly aligned icons. The divider should also appear clean and stable, finally giving you that controlled, modern structure instead of an edge-to-edge layout.

Don't Forget Mobile Responsiveness!

While the above steps cover the main desktop layout, it's crucial to ensure your header looks great on smaller screens too. Namphan shared a great snippet specifically for mobile devices (screens up to 749px wide). This helps adjust the padding and grid layout for a better mobile experience:

@media screen and (max-width: 749px) {
.header__row.header__row--top {
padding-inline-start: 1rem;
padding-inline-end: 1rem;
border: none;
padding-block-start: 1rem;
padding-block-end: 1rem;
}
.header__columns {
grid-template-areas: "rightMenu rightSearch center rightAccount rightCart" !important;
--header-template-columns: var(--header-mobile-bookend) var(--header-mobile-bookend) 1fr var(--header-mobile-bookend) var(--header-mobile-bookend) !important;
border: var(--border-bottom-width) solid var(--color-border);
}
}

Adding this at the bottom of your base.css (or theme.css) file will help fine-tune the mobile layout, ensuring those margins and the overall structure hold up on smaller devices.

Here's a look at the kind of header style Pilotwolf was aiming for (with margins and dividers):

Customizing your Shopify store's appearance can sometimes feel like a puzzle, but with the right insights and a little help from the community, you can achieve some truly fantastic results. This discussion really highlights the power of understanding how modern themes are built and the willingness of fellow store owners and experts to share their knowledge. If you're ever stuck, don't hesitate to share your store URL and password (as Moeed and Devcoders requested in this thread) with trusted community members; it often helps them pinpoint the exact issue much faster. Happy customizing!

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases