Skip to main content
Every Custom Code section consists of three parts: styles, markup, and script. Together, these give you full control over appearance, content, and behavior.

Basic structure

Styles

Place your CSS inside a <style> tag at the top of the section. Always scope styles to section.id to prevent conflicts when multiple instances of the same section exist on a page.
Always use section.id in your CSS selectors. Without it, styles from one section instance will leak into others.

Markup

The markup section contains HTML mixed with Liquid tags and objects. This is where you define the visual structure and dynamic content of your section.

Key objects in markup

Script

Place your JavaScript inside a <script> tag. Scope DOM queries to the section root so multiple instances of the same section don’t interfere with each other, and wrap your code in an IIFE to avoid leaking variables into the global scope.
Always scope DOM queries to the section instance. Using document.querySelector('.toggle') without a section root will match elements across every instance of the section on the page.

Best practices

Scope CSS with section.id

Always include section.id in class names to prevent style conflicts:

Use responsive design

Apply mobile-first styles with media queries:

Check for blank values

Always check if values exist before rendering:

Limit product iterations

Always use the limit filter when iterating over product collections to control performance: