How to Left-Align Text in Anki

How to Left-Align Text in Anki

Anki centers everything by default, so switching to left alignment usually means editing the HTML and CSS yourself. If you don't already know how to edit code, there's no way to go from centered to left-aligned. With ankieditor, though, you don't need any code — one click switches the alignment for you.

Click the part you want to change in ankieditor, then press [Left] under Alignment in "Text Style".

Why Anki's Default Template Is Centered

Anki's built-in note types (Basic, Basic (type in the answer), Cloze) have .card { text-align: center; } in their styling. It's built around the simplest possible card — one word and a one-line meaning. For short content, sitting in the middle of the screen draws the eye well, so it's a reasonable default.

The problem is that the rule applies to the whole card. Even after you add an example sentence, pronunciation, or explanation later, everything stays centered.

When Left Alignment Works Better

In general, Anki's default center alignment works fine. But if a card's sentence runs long or wraps past two lines, left alignment works well too. Here's a basic rundown:

  • A single line like a word or its meaning — center. It's fine to let it sit big in the middle of the card.
  • An example sentence or explanation that runs two lines or more — left. It reads more comfortably that way.
  • Lists or numbered content — left. Centering makes the bullet position shift from line to line.
  • Code or formulas — left. Content where indentation carries meaning doesn't work with center alignment.

How to Switch to Left Alignment in ankieditor

  1. Click the part you want to change in the preview to select it. Clicking empty space selects the whole card.
  2. Press [Left] under Alignment in the left panel's "Text Style".
  3. To change only the example sentence field, click that field to select it, then press the same button. Keeping the whole card centered while left-aligning just the example sentence is a combination that comes up a lot in practice.
  4. Use [Copy Code] to copy the updated code and paste it into Anki's Tools → Manage Note Types → Cards... screen.

The CSS ankieditor Actually Generates

This section explains the CSS that gets changed. If you're using ankieditor, you don't need to know any of this.

Changing the whole card updates the .card rule in the styling area.

.card { text-align: left; }

Changing just one field makes ankieditor issue a class named after that field and write the rule there. Left-aligning the example sentence field looks like this.

.card { text-align: center; }
.Example { text-align: left; }

Having both rules together doesn't cause a conflict — they target different elements. The centering on .card is inherited by everything inside it, but the example sentence field has a .Example rule set directly on it, so that value is used instead of the inherited one. Anki Desktop, AnkiDroid, and AnkiMobile all render cards in a webview, so this CSS generally applies the same way in every environment.

Things to Watch Out For

text-align is inherited by child elements. If you set left on .card, every field inside it becomes left-aligned too. To keep just the word centered, select that field and set it back to [Center].

Justified text (justify) isn't recommended. Because a card is narrow and only a few words fit per line, the spacing between words ends up uneven from line to line, which reads worse than centered text.

Set this separately for each note type. Card templates are stored in the card types that belong to a note type, so if you use several note types, you'll need to apply it to each one.

Frequently Asked Questions

Can I left-align the whole card in Anki?

Yes. Click an empty area of the preview so nothing is selected — that targets the whole card — and choose the alignment you want.

Can I left-align just one field?

Yes. In ankieditor, click that field to select it and press [Left]. You can mix approaches, like keeping the whole card centered and only left-aligning the example sentence.

I left-aligned the card, but some lines are still centered.

That usually means a separate alignment is set on that part. Click that element to select it and press [Left] again. ankieditor clears out inline styles that conflict with the property it's about to apply and writes it to the rule instead, so pressing the button once more fixes it.

For a way to build priority with font size, see How to Change Font Size in Anki; for adjusting line spacing when a paragraph feels cramped, see How to Change Line Spacing in Anki.