How-to
Shopify Size Chart as an HTML Table
A real HTML table beats an image of a table: it is crisp, readable by screen readers, searchable and easy to edit. Here is a table you can paste into a Shopify product description and adapt.
The code is standard HTML. Shopify’s product description editor accepts it in HTML view; your theme’s CSS controls how it looks, so check the result on a phone.
Step by step
- In Shopify admin open Products and choose a product.
- In the description editor, click the
<>(Show HTML) button. - Paste the code below where the chart should go. Edit the numbers.
- Click the button again to return to the visual editor, check it, and save.
The code
<div style="overflow-x:auto;">
<table style="border-collapse:collapse;min-width:360px;width:100%;">
<caption style="text-align:left;font-weight:bold;padding:8px 0;">
Women's tops: body measurements in cm (inches)
</caption>
<thead>
<tr>
<th scope="col" style="text-align:left;border-bottom:1px solid #ccc;padding:6px;">Size</th>
<th scope="col" style="text-align:left;border-bottom:1px solid #ccc;padding:6px;">Bust</th>
<th scope="col" style="text-align:left;border-bottom:1px solid #ccc;padding:6px;">Waist</th>
<th scope="col" style="text-align:left;border-bottom:1px solid #ccc;padding:6px;">Hips</th>
</tr>
</thead>
<tbody>
<tr><th scope="row" style="text-align:left;padding:6px;">S</th><td style="padding:6px;">84-88 (33-34.5)</td><td style="padding:6px;">66-70 (26-27.5)</td><td style="padding:6px;">90-94 (35.5-37)</td></tr>
<tr><th scope="row" style="text-align:left;padding:6px;">M</th><td style="padding:6px;">90-94 (35.5-37)</td><td style="padding:6px;">72-76 (28-30)</td><td style="padding:6px;">96-100 (38-39.5)</td></tr>
<tr><th scope="row" style="text-align:left;padding:6px;">L</th><td style="padding:6px;">96-100 (38-39.5)</td><td style="padding:6px;">78-82 (30.5-32.5)</td><td style="padding:6px;">102-106 (40-42)</td></tr>
</tbody>
</table>
</div>
<p>Measure over light clothing. Between sizes? Choose the larger.</p>
These numbers are an example of the format, not a recommendation for your products. Replace them with your own.
Why this markup
overflow-x:autoon the wrapper lets the table scroll sideways on a phone instead of breaking the layout.<caption>andscopeattributes tell screen readers what the table is and which cell belongs to which header.- Inline styles survive the Shopify editor and do not depend on theme CSS. If your theme styles tables already, you can remove them.
Tips
- Put both units in the same cell (“84-88 (33-34.5)”) so no toggle is needed.
- If your editor strips styles, add the table to a Page (Online Store > Pages) or to a Custom Liquid section in the theme editor, which are less restrictive.
- A table in every product description is hard to maintain. For many products use a metafield-driven block or an app.
- Need a starting chart? Size chart templates include jeans in inches and shoes.
Shopify Size Chart in cm and Inches
If you sell to customers in different countries, a chart in one unit will cost you questions and returns. A toggle lets a shopper pick the unit. This page gives a small version in plain HTML and JavaScript. General guidance, not tested on your theme: use a duplicate theme.
The conversion
1 inch is exactly 2.54 centimetres. To go from inches to cm, multiply by 2.54; from cm to inches, divide by 2.54. Round to one decimal for inches or whole numbers for cm, and keep the rule the same on every chart. Rounding twice (cm to inches to cm) creates drift, so keep one source unit and compute the other.
The code
<div id="sc-wrap">
<button type="button" data-unit="cm" aria-pressed="true">cm</button>
<button type="button" data-unit="in" aria-pressed="false">in</button>
<table>
<thead><tr><th>Size</th><th>Chest</th><th>Waist</th></tr></thead>
<tbody>
<tr><td>S</td><td data-cm="90">90</td><td data-cm="76">76</td></tr>
<tr><td>M</td><td data-cm="98">98</td><td data-cm="84">84</td></tr>
</tbody>
</table>
</div>
<script>
(function () {
var wrap = document.getElementById('sc-wrap');
wrap.addEventListener('click', function (e) {
var unit = e.target.getAttribute('data-unit');
if (!unit) return;
wrap.querySelectorAll('button').forEach(function (b) {
b.setAttribute('aria-pressed', b === e.target ? 'true' : 'false');
});
wrap.querySelectorAll('td[data-cm]').forEach(function (td) {
var cm = parseFloat(td.getAttribute('data-cm'));
td.textContent = unit === 'cm' ? cm : (cm / 2.54).toFixed(1);
});
});
})();
</script>
Every number cell stores its source value in data-cm. The script rewrites the text.
Where to put it
Add it as a Custom Liquid block on the product template, or in the body of a size guide page (HTML view). The steps are the same as in the size chart popup and the HTML table pages.
Checks
- Press each button; the numbers must change and the label must show the active unit.
- Confirm the header says which unit is showing, or add the unit to the button label. Do not leave “cm” in the table title while the cells show inches.
- Compare three rows by hand with a calculator.
- Test on a phone and with the keyboard (Tab, Enter).
- Remember charts such as men’s jeans traditionally use inches: see how to measure waist and inseam for jeans.
Limits
It handles one table per page and numbers only. Ranges such as “90-95” need extra code. If you have many charts, an app is less work than maintaining script. See how to add a size chart in Shopify for the other options, or start with a free template.
To keep the source numbers in one place, build them in a spreadsheet first: size chart template in Google Sheets. A ready set of sizes is in the free templates.
See also: Size Chart Design: 12 Rules for a Chart Shoppers Use · How to Add a Size Chart in WooCommerce (Plugin or Not)