Shopify Horizon guide

How to add custom CSS in the Shopify Horizon theme

What you’ll need

  • A duplicate of your theme to test on

    How to get this: A duplicate of your theme to test on
    1. Online Store › Themes › … on your theme › Duplicate.
    2. Make the change on the copy, preview it, and publish only when it works.

    Step-by-step guide (opens in a new tab)

  • The theme editor (to paste into Theme settings › Custom CSS; no code editing)

    How to get this: The theme editor
    1. Online Store › Themes › Edit theme (on a copy of your theme if you want to test first).
    2. Add section or Add block › Custom Liquid, paste the code, then Save.

    Step-by-step guide (opens in a new tab)

Build Horizon CSS

Add CSS for the whole store

  1. Online Store › Themes › Customize on your Horizon theme (use … › Duplicate first if you want to try it on a copy).
  2. Click the gear icon (Theme settings) in the left bar.
  3. Open Custom CSS at the bottom of the list, paste the code and click Save.
  4. Open the page you changed in the preview to check it.

Add CSS to one section

  1. Online Store › Themes › Customize on your Horizon theme (use … › Duplicate first if you want to try it on a copy).
  2. Click the section in the left bar, for example Product information.
  3. Scroll to the bottom of its settings and open Custom CSS.
  4. Paste the code and Save. Shopify adds the section’s own ID in front of every rule, so the code only touches that section.

What Shopify rejects

  • More than 1,500 characters in Theme settings › Custom CSS, or more than 500 in a section’s box.
  • @import, @charset and @namespace. In a section box, only @media, @container, @layer and @supports are allowed.
  • The content property, and links to files outside cdn.shopify.com.
  • Rules aimed at the section’s own wrapper (the shopify-section element) in a section box.

Why a rule does nothing in Horizon

Horizon prints much of its styling inside the page itself, next to each section and block, after the Custom CSS from Theme settings. When two rules are equally specific, the later one wins, so a plain rule from Theme settings often loses. Add !important to the declaration, or use the section’s own Custom CSS box, which is more specific because Shopify prefixes it with the section ID.

Horizon’s class names can change between theme versions. After you update the theme, open the pages your CSS touches and check it still works.

Questions

Is Custom CSS lost when I update Horizon?

No. Theme settings, including Custom CSS, carry over to the updated version. A rule can stop working if the update renamed the class it targets.

Where does a longer stylesheet go?

Theme code: … › Edit code › Assets › add a new file such as custom.css, and load it from layout/theme.liquid. Code edits are not carried over by a theme update, so keep a copy.

More guides