BlogShopify development

How to Add Custom CSS to Shopify, Step by Step

To add custom CSS to Shopify, go to Online Store, Edit theme, Theme settings, Custom CSS, paste your code and save. One section has its own 500-character box, and bigger changes belong in your theme code.

Work with Ecompanda
Copy as MarkdownSet as Preferred Source
A simplified web page wireframe with a highlighted product element, a paintbrush and a style panel in deep green and chartreuse on a warm off-white background

Custom CSS in Shopify, in short

Generated by Ecompanda AI

Shopify has a Custom CSS box for the whole theme (1,500 characters, every page except checkout) and one for each section (500 characters). Bigger or more complex CSS belongs in your theme code, in an asset file or a stylesheet tag.

  • Whole store: Online Store, Edit theme, Theme settings, Custom CSS, then Save
  • One section: click the section, then Custom CSS at the bottom of its panel
  • Blocked: @import, @charset, @namespace, the content property and URLs outside cdn.shopify.com
  • Custom CSS overrides theme settings and can stop working after a theme update
  • Duplicate the theme and find selectors with DevTools before you write rules

To add custom CSS to your whole Shopify store, go to Online Store, click Edit theme, open Theme settings, click Custom CSS, paste your code and save. To style one section only, click that section in the theme editor and use the Custom CSS box at the bottom of its panel. The theme box holds 1,500 characters, a section box holds 500, and neither one reaches checkout.

That covers most small tweaks. For anything bigger, the CSS belongs in your theme code, and we show how below.

Add custom CSS to your whole theme

Theme-level custom CSS applies to every page of your online store except checkout. These are Shopify's own steps from its Help Center page Add custom CSS:

  1. From your Shopify admin, go to Online Store.
  2. Click Edit theme.
  3. Click Theme settings.
  4. Click Custom CSS.
  5. Add your code.
  6. Click Save.
Shopify Help Center page titled Add custom CSS with six numbered steps, above an illustration of the theme editor with the Custom CSS setting open under Theme settings
Shopify's own steps for adding custom CSS to the whole theme, from the Help Center

One habit before you paste anything: duplicate the theme and try your CSS on the copy. We cover that in the safety section further down.

Add custom CSS to one section

Section CSS only styles the section you add it to. It's the right tool when one banner or one product grid needs a tweak.

  1. From your Shopify admin, go to Online Store and click Edit theme.
  2. In the editor, click the section you want to change.
  3. At the bottom of the section's settings panel, click Custom CSS.
  4. Add your code.
  5. Click Save.

Shopify scopes this CSS to that section. So a plain rule like h2 { letter-spacing: 0.02em; } changes the headings in that section and nowhere else. That makes section CSS shorter to write, which matters with only 500 characters.

What custom CSS can't do

The Custom CSS boxes are built for small style tweaks, not a redesign. Shopify's Add custom CSS page lists these limits:

  • Size. 1,500 characters for the whole theme, 500 for each section.
  • Checkout. Custom CSS isn't supported on the Checkout page.
  • Blocked at-rules. No @import, @charset or @namespace. Section CSS also allows only @media, @container, @layer and @supports.
  • The section wrapper. Section CSS can't target the ID or classes of the wrapper element Shopify adds around every section (the one with the shopify-section class).
  • No content property. So you can't add new ::before or ::after content, though you can restyle ones the theme already draws.
  • Outside files. Any URL in your CSS must point to cdn.shopify.com.
  • Fonts. Custom fonts are allowed, but Shopify says any performance hit is your responsibility.
  • Theme updates. An update can stop your CSS working if the theme's selectors change.
  • Support. Shopify says it doesn't support advanced theme customizations.

One more thing that catches people out: custom CSS overrides your theme settings. If you set a button colour in CSS, changing the colour setting later will seem to do nothing.

The cap is tight, too. Our three examples further down add up to 930 characters as written. Keep comments short or leave them out.

When to move CSS into your theme code

Move to theme code when you hit the character cap, need something the boxes block (like content), or want CSS that ships with a section you built. Shopify's developer docs point the same way. They say the Custom CSS setting is meant for merchants who don't edit code, and tell theme developers to use CSS asset files and stylesheet tags instead.

A shopify.dev page section titled Platform-controlled settings explaining that Shopify exposes a custom CSS setting at theme and section level
Shopify's developer documentation on the Custom CSS setting, shopify.dev

That page also says the box's contents are saved as custom_css, either in a JSON template's section or in settings_data.json. So section CSS belongs to that template, which matters if you want it on one page only (see the FAQ).

There are five places CSS can live. The first two are the boxes above. The other three are theme code.

Five stacked cards numbered one to five: theme settings Custom CSS, section Custom CSS, an asset file, a stylesheet tag and a style tag
The five places CSS can live in a Shopify theme, from quickest to most control
OptionWhereReachesLimits
Theme Custom CSSTheme settings, Custom CSSEvery page except checkout1,500 characters
Section Custom CSSBottom of a section's panelThat section only500 characters, few at-rules
Asset fileEdit code, assets folderWherever you link itNo limit stated
stylesheet tagInside a section, block or snippetPages that render that fileOne tag per file, no Liquid
style tagLiquid, anywhereWhere you output itNo limit stated

Our rule of thumb:

  1. Check for a theme setting first. Colours, fonts, spacing and corner radius are often settings already. Our guide to customizing the Dawn theme shows what they cover.
  2. No setting and a small change? Use a Custom CSS box.
  3. Hit a limit, or need lots of rules? Move to theme code.

To open the code, go to Online Store, open your theme's actions menu and choose Edit code. Shopify's page on editing theme code notes you can only edit a theme's code after buying it. It also warns that code edits which clash with a theme update are left out of the updated copy.

A CSS file in assets

This is what we'd use once a store has more than a handful of overrides. Create assets/custom.css and link it in layout/theme.liquid with the stylesheet_tag filter, which outputs a normal link tag.

{{ 'base.css' | asset_url | stylesheet_tag }}
{{ 'custom.css' | asset_url | stylesheet_tag }}

Put your line after the theme's main stylesheet. In Dawn that's base.css. But Dawn also loads component stylesheets from inside its sections, so load order alone won't always win. Fix the specificity instead (see below).

The stylesheet tag

Sections, blocks and snippets can carry their own CSS in a {% stylesheet %} tag. Shopify collects these into one generated styles.css file.

<div class="featured-note">{{ section.settings.text }}</div>

{% stylesheet %}
  .featured-note { padding: 1.6rem; border-radius: 12px; }
{% endstylesheet %}

Shopify's JavaScript and stylesheet tags page sets two rules: one stylesheet tag per file, and no Liquid inside it.

There's a newer catch. Since 20 April 2026, Shopify only sends the stylesheet CSS for files rendered on each page, per its changelog. So a class defined in one section and used in an unrelated one can go missing. The subsetting docs say asset stylesheets and {% style %} tags aren't affected. Put shared, site-wide classes in an asset file.

The style tag

The Liquid style tag does render Liquid, so use it when CSS should follow a theme setting. Shopify notes that colour settings used inside it update live in the theme editor, without a page refresh. Setting names differ between themes.

{% style %}
  :root { --accent: {{ settings.colors_accent_1 }}; }
{% endstyle %}

Our Liquid templating guide goes deeper on tags and filters.

Find the right selector with DevTools

Most CSS that "doesn't work" has the wrong selector. So look at what the theme actually outputs.

  1. Right-click the element and choose Inspect.
  2. In the Elements panel, check the highlighted node is the one you mean.
  3. Read the Styles pane. It lists every matching rule with its file, and strikes through declarations that lost.
  4. Open the Computed tab to see the final value.
  5. Try values live. Edits vanish on reload, so copy what works. Chrome explains this in View and change CSS.
Chrome DevTools beside the Dawn demo store with a product title h3 selected and the Styles pane listing matching rules, some declarations struck through
Chrome DevTools on Shopify's public Dawn demo store with a product title selected, theme-dawn-demo.myshopify.com

Here we picked a Dawn product title: an h3 with the classes card__heading and h5. The Styles pane shows a short .card__heading rule from component-card.css, and heading sizes from base.css struck through. That tells you which class to target.

  • Pick readable classes like .card__heading. Skip ids like #shopify-section-template--15968257704025__featured_collection. They belong to one section instance and can change.
  • Watch for overlays. Dawn stretches a ::after across each card to make the whole card clickable. Our first click landed on it. Pick the heading in the Elements tree instead.

Why your custom CSS isn't working

If your rule shows in the Styles pane but is struck through, another rule beat it. The browser checks importance first, then cascade layers, then specificity, then source order.

Three horizontal bars comparing the specificity of star focus-visible, focus-inset focus-visible and focus-visible repeated three times, with the third highlighted as the winner
How three focus rules compare on specificity, with the highest score winning

Specificity counts ids, then classes and pseudo-classes, then element names. MDN's specificity guide notes that the universal selector and :where() add nothing. On a tie, the later rule wins. Our ladder, gentlest first:

  1. Add one class. If the theme styles .card__heading, write .card-wrapper .card__heading.
  2. Repeat a pseudo-class. :focus-visible:focus-visible:focus-visible outscores .focus-inset:focus-visible. Leave a comment saying why.
  3. Last resort. Use !important only for rules that must win everywhere. It beats your own later rules too.

And watch out for layers. Normal styles outside a layer beat layered ones, per MDN's @layer page. Dawn's base.css has no @layer rules. So wrapping your overrides in @layer to keep them tidy would make them lose.

Three tested examples for the Dawn theme

When we first wrote this guide, we injected each snippet into Shopify's public Dawn demo store (theme-dawn-demo.myshopify.com) in Chrome, at 1,440 and 390 pixel widths, which touches no real store. The demo may have changed since. We couldn't paste into a Custom CSS box there, so check your box accepts each rule. We didn't test Safari or Firefox. The selectors are Dawn's, so inspect your own theme first.

A sticky announcement bar

Dawn's announcement bar scrolls away. This pins it and pushes the sticky header down so the two stack. Use the theme-level box.

:root { --bar-h: 39px; }
.announcement-bar-section { position: sticky; top: 0; z-index: 5; }
.shopify-section-header-sticky { top: var(--bar-h); }
.shopify-section-header-hidden { top: calc(var(--bar-h) - var(--header-height)); }
html { scroll-padding-top: calc(var(--bar-h) + var(--header-height) + 1rem); }
Top: a Dawn page scrolled down with no announcement bar. Bottom: the same scroll position with the announcement bar pinned at the top
The Dawn demo store scrolled down, before and after the sticky bar CSS, theme-dawn-demo.myshopify.com
  • The bar measured 39 pixels at both widths. Measure yours and change --bar-h. A bar that wraps on phones is taller.
  • z-index: 5 sits above Dawn's header at 3, so the header slides behind the bar when it hides. --header-height is a Dawn variable; other themes won't have it.
  • The last line is for keyboard users. Without it, a link target landed at 0 pixels, under the sticky bars. With it, 134 pixels down. WCAG 2.2 2.4.11 Focus Not Obscured (Minimum) asks that a focused item isn't fully hidden by content you added.

Tidier product cards

This clamps long titles to two lines, lines up price digits and tones down the struck-through old price so the sale price leads.

.card-wrapper .card__heading a {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.card-wrapper .price { font-variant-numeric: tabular-nums; }
.card-wrapper .price__sale s { font-size: 0.85em; opacity: 0.85; }
.card-wrapper .price-item--sale { font-weight: 600; }
@media (max-width: 749px) {
  .card-wrapper .card__heading { font-size: 1.4rem; }
}
Top: four Dawn product cards with default prices. Bottom: the same cards with bold sale prices and struck-through old prices at 0.85 opacity
Four product cards on the Dawn demo store, before and after the card CSS with the old price at 0.85 opacity, theme-dawn-demo.myshopify.com
  • A long test title ran to five lines on desktop and six on a phone. With the CSS, two on both. The full title stays in the page for screen readers.
  • The clamp sits on the link, not the h3. When we put overflow: hidden on the heading, the keyboard focus ring got clipped and vanished.
  • Dawn already shows the old price at 75 percent of the text colour. With opacity 0.85 on top, it works out to about 5.6 to 1 against white by our calculation, above the 4.5 to 1 in WCAG 1.4.3. At 0.65 it drops to about 3.4 to 1 and fails.

A clearer focus ring

Dawn draws a grey focus outline at 50 percent opacity. By our calculation that's about 3.5 to 1 over white, which only just clears the 3 to 1 minimum in WCAG 1.4.11. This ring is solid and follows each section's colour scheme.

:focus-visible:focus-visible:focus-visible {
  outline: 3px solid rgb(var(--color-foreground, 18, 18, 18));
  outline-offset: 3px;
  box-shadow: 0 0 0 3px rgb(var(--color-background, 255, 255, 255));
}
Top: a grey keyboard focus ring around the Lookbook link in the Dawn header. Bottom: a thick black ring around the same link
Keyboard focus on the Lookbook link in the Dawn header, before and after the ring CSS, theme-dawn-demo.myshopify.com
  • :focus-visible shows the ring to keyboard users without drawing it on every mouse click (MDN). WCAG 2.4.7 requires a visible focus indicator at level AA.
  • The tripled pseudo-class beat Dawn's .focus-inset, .button and * focus rules. We tabbed through header links, buttons, form fields and the footer, and each showed the new ring.
  • --color-foreground and --color-background are Dawn's colour scheme variables, so a dark section gets a light ring. The numbers after the commas are fallbacks.
  • A parent with overflow: hidden can clip a 3 pixel offset. Tab through your header, slideshow and drawers to check.

Mobile, colour schemes and motion

Mobile. Dawn's stylesheet splits layouts at 750 pixels (min-width: 750px and max-width: 749px) and again at 990. Write @media (max-width: 749px) to match that split with no gap. Section CSS allows @media and @container, so this works in a section box too. Keep tap targets at least 24 by 24 CSS pixels (WCAG 2.5.8) and keep sticky bars to one line on phones.

Colour schemes. Dawn colours each section through schemes you pick in the editor. Each section gets a class such as color-background-1 (newer installs use names like color-scheme-1) that sets --color-foreground and --color-background. Use those variables and your CSS follows the section.

Dawn has no prefers-color-scheme rules, so we'd skip bolting a dark mode on in custom CSS. You'd own every colour it touches, and a half-dark page is easy to end up with.

Motion. Wrap animation in @media (prefers-reduced-motion: no-preference), and animate transform and opacity. Shopify's performance guidance prefers those over animating layout properties.

Keep your changes safe

  • Duplicate the theme first. In Online Store, open the theme's actions menu and choose Duplicate. Edit the copy, preview it, then publish. Shopify allows up to 20 themes, so you may need to delete an old one.
  • Change one thing at a time, and save between changes.
  • Know the undo. Each code file has a Timeline view that restores that one file to an earlier version. It can't restore a whole theme or a deleted file. Restoring replaces the whole file, so copy the current version first.
  • Keep notes outside Shopify. Write down each rule and why you added it. After an update you'll know exactly what to check.
  • Check after theme updates. Shopify's updating themes page says editor customizations carry over and non-conflicting code edits come along. If you added custom CSS, check your selectors still exist. Review the "Updated copy of" draft before you publish it.

A few hundred characters of CSS cost almost nothing in speed. Fonts and extra files are the real cost. Shopify's performance guide says web fonts are render-blocking by default and can shift the layout when they swap in. It also says each extra stylesheet link triggers an expensive style recalculation, so one asset file beats five.

And a short list of things we'd never do:

  • Paste CSS from a forum into the live theme without reading it.
  • Use outline: none without a replacement focus style that's just as visible.
  • Scatter !important everywhere instead of fixing the specificity.
  • Hide legal links, prices or form labels because they look untidy.

More habits are in our piece on best practices for theme customization.

Frequently asked questions

Where do I add custom CSS in Shopify?

In the theme editor. For the whole store: Online Store, Edit theme, Theme settings, Custom CSS. For one section: click the section and use Custom CSS at the bottom of its panel. For bigger sets of rules, use Edit code and link a CSS file from layout/theme.liquid.

How many characters can Shopify's Custom CSS box hold?

1,500 characters for the theme-wide box and 500 for each section, per Shopify's Help Center. The theme code pages we read state no such limit, which is why bigger jobs go in an asset file.

Can I add custom CSS to just one page?

Not with the boxes alone, as we read Shopify's docs. Section CSS is saved inside the JSON template that holds the section, so we'd expect it on every page using that template. To style one product or page, create an alternate template, assign it to that page, then add your section CSS there. Our guide to sections and blocks explains how templates and sections fit together.

Why is my custom CSS not working in Shopify?

First check you clicked Save. Then inspect the element. If your rule is struck through, a more specific theme rule won. If it doesn't show up at all, the selector doesn't match, or the rule is in the wrong section's box. Remember that section CSS can't target the section wrapper, and DevTools edits vanish on reload.

Will my custom CSS survive a theme update?

It's copied over, but it may stop working. Shopify says editor customizations move to the updated theme, but depending on your selectors an update might break your CSS. Add the update as a draft, check your selectors still exist, then publish.

Can I add custom CSS to Shopify checkout?

No. Shopify's Help Center says custom CSS isn't supported on the Checkout page, and theme CSS doesn't reach it. For checkout changes, read Shopify's current checkout customization docs or ask a developer.

Do I need to know CSS to use the Custom CSS box?

A little. You need to read a selector, know a few properties, and use DevTools to inspect the page. If a change needs more than the box allows, that's usually the point to bring in a developer.

Where we can help

We build and maintain Shopify themes, including CSS changes that survive theme updates. If you want a second pair of eyes on your theme code, or someone to handle a bigger set of changes, get in touch.

Sources

The pages this guide rests on. Read the current version before you rely on a detail.

← All guidesMore on shopify development

Related content

More on shopify development

All guides

Shopify development

Shopify Liquid cheat sheet and guide: syntax, tags, filters and objects

Shopify Liquid is the template language Shopify themes use to turn store data into HTML. This page gives you a cheat sheet of its syntax, tags, filters, objects and comments, then the patterns and checks that keep theme code working.

Shopify development

Shopify Theme Customization: A Safe Workflow and Review Checklist

To customize a Shopify theme safely, use the theme editor first, do code work on a copy, run Theme Check and a review checklist, then publish with the old theme kept for rollback. This guide covers each step and what to do when a theme won't stretch far enough.

Free newsletter

Enjoying this guide? Get one tactic like it every week.

Short notes on Shopify, AI search and conversion, taken from our own work. Unsubscribe in one click.

Let’s make your store your best salesperson.

Tell us where your brand is headed in the next twelve months and we will show you how your store can get it there. Book a 15 minute call or send us a message, and we reply within one business day.

Replies within one business day