How can I center a button in an email template?

Topic summary

A user is struggling to center the “View your order” button in Shopify email templates. While style="text-align: center;" successfully centers the logo and other text elements, it doesn’t work on the button itself.

Proposed Solution:

Another user suggests that email HTML requires different styling approaches than web design. The recommended fix involves:

  • Adding align="center" to the <table> element wrapping the button
  • Adding style="text-align: center;" to the <td> element containing the button
  • Adding style="display: inline-block; text-align: center;" to the button’s <a> tag

The issue remains unresolved as the original poster hasn’t confirmed whether this solution worked.

Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

Hi all,

I’ve been trying the last few days and searching google to find out how to centre buttons in the email templates which are send to customers. I can’t find anything. I’ve tried style=“text-align: center;” which works on the logo a the text that says ‘or visit our store’. However, this isn’t woking on ‘view your order’ button.

Here is my code;

{% capture email_title %}
{% if has_pending_payment %}
Thank you for your order!
{% else %}
Thank you for your order!
{% endif %}
{% endcapture %}
{% capture email_body %}
{% if has_pending_payment %}
{% if buyer_action_required %}
You’ll get a confirmation email after completing your payment.
{% else %}
Your payment is being processed. You’ll get an email when your order is confirmed.
{% endif %}
{% else %}
{% if requires_shipping %}
{% case delivery_method %}
{% when ‘pick-up’ %}
You’ll receive an email when your order is ready for pickup.
{% when ‘local’ %}
Hi {{ customer.first_name }}, we’re getting your order ready for delivery.
{% else %}
We’re getting your order ready to be shipped. We will notify you when it has been sent.
{% endcase %}
{% if delivery_instructions != blank %}

Delivery information: {{ delivery_instructions }}

{% endif %} {% if consolidated_estimated_delivery_time %}

Estimated delivery {{ consolidated_estimated_delivery_time }}

{% endif %} {% endif %} {% endif %} {% assign gift_card_line_items = line_items | where: "gift_card" %} {% assign found_gift_card_with_recipient_email = false %} {% for line_item in gift_card_line_items %} {% if line_item.properties["__shopify_send_gift_card_to_recipient"] and line_item.properties["Recipient email"] %} {% assign found_gift_card_with_recipient_email = true %} {% break %} {% endif %} {% endfor %} {% if found_gift_card_with_recipient_email %}

Your gift card recipient will receive an email with their gift card code.

{% elsif gift_card_line_items.first %}

You’ll receive separate emails for any gift cards.

{% endif %} {% endcapture %} {{ email_title }} .button__cell { background: {{ shop.email_accent_color }}; } a, a:hover, a:active, a:visited { color: {{ shop.email_accent_color }}; }
{%- if po_number %} {%- endif %}
{%- if shop.email_logo_url %} {{ shop.name }} {%- else %}

{{ shop.name }}

{%- endif %}
Your Order Number is: {{ order_name }}
PO number #{{ po_number }}

{{ email_title }}

{{ email_body }}

{% assign transaction_count = transactions | size %} {% if transaction_count > 0 %} {% for transaction in transactions %} {% if transaction.show_buyer_pending_payment_instructions? %}

{{transaction.buyer_pending_payment_notice}}

{% for instruction in transaction.buyer_pending_payment_instructions %} {% endfor %} {% for instruction in transaction.buyer_pending_payment_instructions %} {% endfor %}
{{ instruction.header }}Amount
{{ instruction.value }}{{transaction.amount | money}}

{% endif %} {% endfor%} {% endif %}

{% if order_status_url %}

{% else %}
{% if shop.url %}

Visit our store
{% endif %}

{% endif %}

Order summary

{% for line in subtotal_line_items %} {% endfor %}
{% if line.image %} {% endif %} {% if line.product.title %} {% assign line_title = line.product.title %} {% else %} {% assign line_title = line.title %} {% endif %}

{% if line.quantity < line.quantity %}
{% capture line_display %} {{ line.quantity }} of {{ line.quantity }} {% endcapture %}
{% else %}
{% assign line_display = line.quantity %}
{% endif %}

{{ line_title }} × {{ line_display }}

{% if line.variant.title != ‘Default Title’ %}
{{ line.variant.title }}

{% endif %}

{% for group in line.groups %}
Part of: {{ group.display_title }}

{% endfor %}

{% if line.gift_card and line.properties[“__shopify_send_gift_card_to_recipient”] %}
{% for property in line.properties %}
{% assign property_first_char = property.first | slice: 0 %}
{% if property.last != blank and property_first_char != ‘_’ %}

{{ property.first }}:
{% if property.last contains '/uploads/' %} {{ property.last | split: '/' | last }} {% else %} {{ property.last }} {% endif %}
{% endif %} {% endfor %}

{% endif %}

{% if line.selling_plan_allocation %}
{{ line.selling_plan_allocation.selling_plan.name }}

{% endif %}

{% if line.refunded_quantity > 0 %}
Refunded
{% endif %}

{% if line.discount_allocations %}
{% for discount_allocation in line.discount_allocations %}
{% if discount_allocation.discount_application.target_selection != ‘all’ %}

{{ discount_allocation.discount_application.title | upcase }} (-{{ discount_allocation.amount | money }})

{% endif %} {% endfor %} {% endif %}
{% if line.original_line_price != line.final_line_price %} {{ line.original_line_price | money }} {% endif %}

{% if line.final_line_price > 0 %} {{ line.final_line_price | money }} {% else %} Free {% endif %}

{% assign order_discount_count = 0 %}
{% assign total_order_discount_amount = 0 %}
{% assign has_shipping_discount = false %}

{% for discount_application in discount_applications %}
{% if discount_application.target_selection == ‘all’ and discount_application.target_type == ‘line_item’ %}
{% assign order_discount_count = order_discount_count | plus: 1 %}
{% assign total_order_discount_amount = total_order_discount_amount | plus: discount_application.total_allocated_amount %}
{% endif %}
{% if discount_application.target_type == ‘shipping_line’ %}
{% assign has_shipping_discount = true %}
{% assign shipping_discount = discount_application.title %}
{% assign shipping_amount = discount_application.total_allocated_amount %}
{% endif %}
{% endfor %}

{% if order_discount_count > 0 %}
{% if order_discount_count == 1 %}

{% endif %}
{% if order_discount_count > 1 %}

{% endif %}
{% for discount_application in discount_applications %}
{% if discount_application.target_selection == ‘all’ and discount_application.target_type != ‘shipping_line’ %}

{% endif %}
{% endfor %}
{% endif %}

{% if delivery_method == ‘pick-up’ %}

{% else %}
{% if has_shipping_discount %}

{% else %}

{% endif %}

{% endif %}

{% if total_duties %}

{% endif %}

{% if total_tip and total_tip > 0 %}

{% endif %}

Subtotal

{{ subtotal_price | plus: total_order_discount_amount | money }}

Order Discount

-{{ total_order_discount_amount | money }}

Order Discounts

-{{ total_order_discount_amount | money }}

{{ discount_application.title }} (-{{ discount_application.total_allocated_amount | money }})

Pickup

{{ shipping_price | money }}

Shipping

Free

{{ shipping_discount }} (-{{ shipping_amount | money }})

Shipping

{{ shipping_price | money }}

Duties

{{ total_duties | money }}

Taxes

{{ tax_price | money }}

Tip

{{ total_tip | money }}
{% assign transaction_size = 0 %} {% assign transaction_amount = 0 %} {% for transaction in transactions %} {% if transaction.status == "success" %} {% unless transaction.kind == "authorization" or transaction.kind == "void" %} {% assign transaction_size = transaction_size | plus: 1 %} {% assign transaction_amount = transaction_amount | plus: transaction.amount %} {% endunless %} {% endif %} {% endfor %} {% if payment_terms and payment_terms.automatic_capture_at_fulfillment == false or b2b?%} {% assign due_at_date = payment_terms.next_payment.due_at | date: "%b %d, %Y" %}
{% else %}

{% endif %}

Total paid today

{{ transaction_amount | money_with_currency }}

Total due {{ due_at_date }}

{{ payment_terms.next_payment.amount_due | money_with_currency }}

Total

{{ total_price | money_with_currency }}

{% if total_discounts > 0 %}

You saved {{ total_discounts | money }}

{% endif %}

{% unless payment_terms %}
{% if transaction_size > 1 or transaction_amount < total_price %}

{% for transaction in transactions %}
{% if transaction.status == “success” and transaction.kind == “capture” or transaction.kind == “sale” %}
{% if transaction.payment_details.credit_card_company %}
{% capture transaction_name %}{{ transaction.payment_details.credit_card_company }} (ending in {{ transaction.payment_details.credit_card_last_four_digits }}){% endcapture %}
{% else %}
{% capture transaction_name %}{{ transaction.gateway_display_name }}{% endcapture %}
{% endif %}

{% endif %}
{% if transaction.kind == ‘refund’ %}
{% if transaction.payment_details.credit_card_company %}
{% assign refund_method_title = transaction.payment_details.credit_card_company %}
{% else %}
{% assign refund_method_title = transaction.gateway %}
{% endif %}

{% endif %}
{% endfor %}

{{transaction_name}}

{{ transaction.amount | money }}

Refund
{{ refund_method_title | capitalize }}

- {{ transaction.amount | money }}
{% endif %}

{% endunless %}

 
View your order

{% if shop.url %}

{% endif %}

or Visit LoveMalita.com

Your information

{% if requires_shipping and shipping_address %} {% endif %} {% if billing_address %} {% endif %}

Shipping address

{{ shipping_address | format_address }}

Billing address

{{ billing_address | format_address }}
{% if company_location %} {% endif %} {% if transaction_size > 0 or payment_terms and payment_terms.automatic_capture_at_fulfillment == false or b2b? %} {% endif %} {% if requires_shipping and shipping_address %} {% if shipping_method %} {% endif %} {% endif %}

Location

{{ company_location.name }}

Payment

{% if payment_terms %} {% assign due_date = payment_terms.next_payment.due_at | default: nil %} {% if payment_terms.type == 'receipt' or payment_terms.type == 'fulfillment' and payment_terms.next_payment.due_at == nil %} {{ payment_terms.translated_name }}
{% else %} {{ payment_terms.translated_name }}: Due {{ due_date | date: format: 'date' }}
{% endif %} {% endif %} {% if transaction_size > 0 %} {% for transaction in transactions %} {% if transaction.status == "success" or transaction.status == "pending" %} {% if transaction.kind == "capture" or transaction.kind == "sale" %} {% if transaction.payment_details.credit_card_company %} {{ transaction.payment_details.credit_card_company }} ending with {{ transaction.payment_details.credit_card_last_four_digits }}
{% elsif transaction.gateway_display_name == "Gift card" %} ending with {{ transaction.payment_details.gift_card.last_four_characters | upcase }}
    Gift card balance - {{ transaction.payment_details.gift_card.balance | money }} {% elsif transaction.gateway_display_name != "Shop Cash" %} {{ transaction.gateway_display_name }}
{% endif %} {% elsif transaction.kind == "authorization" and transaction.gateway_display_name == "Shop Cash" %} Shop Cash - {{ transaction.amount | money }} {% endif %} {% endif %} {% endfor %} {% endif %}

Shipping method

{% if delivery_promise_branded_shipping_line %} {{ delivery_promise_branded_shipping_line }} {% else %} {{ shipping_method.title }} {% endif %}

If you have any questions, reply to this email or contact us at {{ shop.email }}

1 Like

Hi @LoveMalita

Maybe email HTML is different from web design, so buttons need extra styling to align properly.

To center the “View your order” button in your Shopify email template, modify the containing the button by ensuring it has text-align: center;. Also, make sure the table wrapping the button is centered.

You can try these steps to fix this:

Find this part of your code





View your order

Modify it like this






View your order

Hope this work for you

Best regards,

Daisy.