# Collect tax with Checkout elements

Learn how to calculate and display taxes using Checkout with elements mode.

Stripe Tax automatically calculates the taxes on purchases when you use Checkout with elements mode (`ui_mode: 'elements'`). This integration gives you full control over the payment form layout while Stripe handles tax calculation.

If you haven’t set up Checkout with elements mode, complete the Checkout quickstart first.

## Calculate and render tax amount

Use Stripe Tax to automatically calculate the tax on your transactions without requiring you to define the rates and rules. Fees only apply after you add at least one location where you’re registered to calculate and remit tax.

## Configure your Checkout Session to collect tax

To start collecting tax:

1.  Pass `automatic_tax[enabled]=true` when creating a Checkout Session.
2.  Specify a `tax_code` for each line item, or set a preset tax code in the Dashboard.
3.  Specify a `tax_behavior` for each line item, or set a default tax behavior in the Dashboard.

This code enables automatic tax calculation using Stripe Tax, a tax code, and a tax behavior. Stripe Tax then uses the tax code and tax behavior to automatically calculate taxes.

```bash
curl https://api.stripe.com/v1/checkout/sessions \
  -u "sk_test_RXHltS2OKzISvxWQ7NmRN57i001oa6x7o4:" \
  -d "line_items[0][price_data][currency]=usd" \
  -d "line_items[0][price_data][product_data][name]=T-shirt" \
  -d "line_items[0][price_data][product_data][tax_code]=txcd_99999999" \
  -d "line_items[0][price_data][unit_amount]=2000" \
  -d "line_items[0][price_data][tax_behavior]=exclusive" \
  -d "line_items[0][quantity]=1" \
  -d mode=payment \
  -d ui_mode=elements \
  -d return_url={{RETURN_URL}}
```