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.

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.
Try Shopify free
Open a store, set up your first products and test the ideas in this guide as you read.
Start free trialAffiliate link. We may earn a commission at no cost to you.
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:
- From your Shopify admin, go to Online Store.
- Click Edit theme.
- Click Theme settings.
- Click Custom CSS.
- Add your code.
- Click Save.

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.
- From your Shopify admin, go to Online Store and click Edit theme.
- In the editor, click the section you want to change.
- At the bottom of the section's settings panel, click Custom CSS.
- Add your code.
- 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,@charsetor@namespace. Section CSS also allows only@media,@container,@layerand@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-sectionclass). - No
contentproperty. So you can't add new::beforeor::aftercontent, 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.

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.

| Option | Where | Reaches | Limits |
|---|---|---|---|
| Theme Custom CSS | Theme settings, Custom CSS | Every page except checkout | 1,500 characters |
| Section Custom CSS | Bottom of a section's panel | That section only | 500 characters, few at-rules |
| Asset file | Edit code, assets folder | Wherever you link it | No limit stated |
| stylesheet tag | Inside a section, block or snippet | Pages that render that file | One tag per file, no Liquid |
| style tag | Liquid, anywhere | Where you output it | No limit stated |
Our rule of thumb:
- 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.
- No setting and a small change? Use a Custom CSS box.
- 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.
- Right-click the element and choose Inspect.
- In the Elements panel, check the highlighted node is the one you mean.
- Read the Styles pane. It lists every matching rule with its file, and strikes through declarations that lost.
- Open the Computed tab to see the final value.
- Try values live. Edits vanish on reload, so copy what works. Chrome explains this in View and change CSS.

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
::afteracross 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.

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:
- Add one class. If the theme styles
.card__heading, write.card-wrapper .card__heading. - Repeat a pseudo-class.
:focus-visible:focus-visible:focus-visibleoutscores.focus-inset:focus-visible. Leave a comment saying why. - Last resort. Use
!importantonly 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); }
- The bar measured 39 pixels at both widths. Measure yours and change
--bar-h. A bar that wraps on phones is taller. z-index: 5sits above Dawn's header at 3, so the header slides behind the bar when it hides.--header-heightis 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; }
}
- 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 putoverflow: hiddenon 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));
}
:focus-visibleshows 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,.buttonand*focus rules. We tabbed through header links, buttons, form fields and the footer, and each showed the new ring. --color-foregroundand--color-backgroundare Dawn's colour scheme variables, so a dark section gets a light ring. The numbers after the commas are fallbacks.- A parent with
overflow: hiddencan 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: nonewithout a replacement focus style that's just as visible. - Scatter
!importanteverywhere 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.
- Shopify Help Center: Add custom CSS
- Shopify Help Center: Edit theme code
- Shopify Help Center: Duplicating themes
- Shopify Help Center: Updating themes
- shopify.dev: Theme settings, platform-controlled settings
- shopify.dev: JavaScript and stylesheet tags
- shopify.dev: Stylesheet content subsetting
- shopify.dev: Liquid style tag
- shopify.dev: Alternate templates
- shopify.dev: Performance best practices for themes
Shopify agency
We build, fix and grow Shopify stores.
Tell us what you are working on. We reply by email within one business day.
Work with Ecompanda


