I have this custom CSS code for gradient style for the h3 text in my product template but i cannot use it in the shopify theme editor section’s custom CSS field as there is other code and i have reached 500 character limit.
How can I add this code to the styles.css file but fix it only to that specific product or product template so it does not affect the entire website h3 style?
Product template file name is: product.shorty.json
Because the selector is .template-shorty h3 instead of just h3, it only fires when the page’s has that class, i.e., only when a product is rendered using product.shorty.json.
Since it now lives in styles.css, delete it from the section’s custom CSS box to free up your character limit.
Since several solutions already use inline CSS, another clean approach is to create a separate stylesheet and load it only when the product.shorty.json template is being used.
1. Create a dedicated CSS file
Go to:
Online Store > Themes > Edit code > Assets > Add a new asset
Open layout/theme.liquid and add this before </head>:
{% if request.page_type == 'product' and template.suffix == 'shorty' %}
{{ 'product-shorty.css' | asset_url | stylesheet_tag }}
{% endif %}
3. Add the class to the required heading
Instead of styling every h3 on the template, add the class only to the heading that needs the gradient:
<h3 class="product-shorty-gradient">
Your heading text
</h3>
This is safer than targeting all h3 elements because other section headings, product recommendations, app content, or accordion headings on the same template will remain unchanged.
It also keeps the code outside the 500-character Custom CSS field and prevents the additional stylesheet from loading on the rest of the store.
You can add the CSS to your styles.css (or base.css, depending on your theme), but avoid targeting all h3 elements globally, as that will affect every h3 across your store.
Instead, scope the CSS to your specific product template. For example:
If your theme doesn’t output the template--product-shorty class on the <body>element, inspect the page using your browser’s developer tools to find the correct template or body class. You can then replace the selector accordingly, or wrap the relevant section in a custom class and target that instead.