How to fix avoid inline spacing on Adobe Commerce (Magento)

Remove hard-coded text-spacing CSS properties from inline `style` attributes so users can override them with their own stylesheets.

Steps for Adobe Commerce (Magento)

  1. Identify the template file responsible: check `app/design/frontend/<Vendor>/<Theme>/` for `.phtml` files or `.html` Knockout/UI-component templates that output `style=` with spacing properties.
  2. In your custom child theme, create an override of the offending template (copy it to `app/design/frontend/<YourVendor>/<YourTheme>/`) and remove the inline spacing property from the `style` attribute.
  3. Add a CSS class to the element and define the spacing in `web/css/source/_module.less` or `web/css/source/_extend.less` under that class.
  4. If spacing is injected via a CMS block or Page Builder widget (in Commerce), go to Content → Blocks or Content → Pages, edit the block, switch to HTML view, find and remove the inline `style` spacing property, and instead apply a CSS class.
  5. Run `bin/magento setup:static-content:deploy` and clear the cache (`bin/magento cache:flush`) to deploy updated styles.
  6. Verify with axe DevTools.
Official Adobe Commerce (Magento) documentation ↗
<!-- BEFORE: inline spacing blocks user overrides -->
<p style="line-height: 1.4; letter-spacing: 0.05em;">Product description text</p>

<!-- AFTER: spacing lives in the stylesheet, users can override it -->
<p class="product-description">Product description text</p>

/* In your stylesheet */
.product-description {
  line-height: 1.4;
  letter-spacing: 0.05em;
}

What is avoid inline spacing?

Inline spacing refers to CSS properties like `line-height`, `letter-spacing`, `word-spacing`, and `margin-top`/`padding-top` (used to control text block spacing) that are written directly inside an HTML element's `style="…"` attribute rather than in a separate stylesheet. When these values are hard-coded inline, a user's browser or assistive-technology stylesheet cannot override them — even when that user has set their own spacing preferences to make text readable. WCAG 2.1 Success Criterion 1.4.12 ("Text Spacing") requires that users can adjust those four specific spacing properties without losing content or functionality.

Roughly 1 in 5 people have a disability that affects how they read text, and many of them rely on custom browser stylesheets or accessibility extensions that increase letter spacing, line height, or word spacing to make text legible. When your store hard-codes those values inline, their overrides are silently blocked, making your content unreadable for those shoppers — driving them directly to a competitor. Beyond lost sales, WCAG 2.1 Level AA compliance (which includes SC 1.4.12) is the baseline required by accessibility laws in the EU (EAA), UK (PSBAR), Canada (AODA), and increasingly enforced in the US under the ADA. Non-compliance exposes your business to legal complaints, demand letters, and lawsuits.

See the complete Avoid inline spacing guide for every platform and the full background.

Not sure if your Adobe Commerce (Magento) store has this?

Run a free SEOLZ audit — we’ll find avoid inline spacing and every other issue across your whole site.

Scan my site free

Fix avoid inline spacing on another platform