Card Styling
You can watch a video about styling cards on YouTube. The video shows Anki 2.0’s interface, but the concepts are largely the same. The styling section of the Cards screen can be accessed by clicking the “Styling” button next to the “Back Template” button. In that section, you can change the background color of the card, the default font, the text alignment, and so on. The standard options available to you are: font-familyThe name of the font to use on the card. If your font has spaces in it like “MS Unicode”, then you need to surround the font name in double quotes, like
font-family: "MS Unicode";. It is also possible to use multiple fonts on
one card; for information on that, please see below.
font-sizeThe size of the font in pixels. When changing it, make sure you leave px at the end. text-align
Whether the text should be aligned in the center, left, or right. color
The color of the text. Simple color names like “blue”, “lightyellow”, and so on will work, or you can use HTML color codes to select arbitrary colors. Please see this webpage for more information. background-color
The color of the card background. Any CSS can be placed in the styling section – advanced users may wish to do things like add a background image or gradient, for example. If you’re wondering how to get some particular formatting, please search the web for information about how to do it in CSS, as there is a great deal of documentation available. The styling is shared between all cards, which means that when you make an adjustment it will affect all cards for that note type. It is also possible to specify card-specific styling, however. The following example will use a yellow background on all cards except the first one:
Image Resizing
Anki shrinks images to fit the screen by default. You can change this by adding the following to the bottom of your styling section (outside of the default.card { ... }):
!important to each style directive, for
example:
Field Styling
The default styling applies to the whole card. You can also make certain fields or part of the card use a different font, color, and so on. This is particularly important when studying foreign languages, as Anki will sometimes be unable to correctly display characters unless an appropriate font has been chosen. Say you have an “Expression” field, and you want to give it the macOS Thai font “Ayuthaya”. Imagine your template already reads:Audio Replay Buttons
When audio or text to speech is included on your cards, Anki will show buttons you can click on to replay the audio. If you prefer not to see the buttons, you can hide them in the preferences screen. You can customize their appearance in your card styling, for example, to make them smaller and colored, you could use the following:Text Direction
If you use a language that is written right-to-left, such as Arabic or Hebrew, you can add the CSSdirection property to the .card section for correct display during review:
Displaying Code Snippets
If you want to include code in your Anki cards, you can use HTML tags to format text as code. For that, you need to open the HTML view.Inline code
Wrap your text with the<code> tag:
Code blocks
Use<pre><code> for multi-line code:
Other HTML
Your templates can contain arbitrary HTML, which means that all the layout possibilities used on internet web pages can also be used on your cards. Things like tables, lists, images, links to external pages and so on are all supported. With tables for example, you could change the layout so that the front and back of a card appear on the left and right instead of the top and bottom. Covering all of HTML’s features is outside the scope of this manual, but there are plenty of good introductory guides to HTML available on the web if you’d like to learn more.Browser Appearance
If your card templates are complex, it may be difficult to read the question and answer columns (called “Front” and “Back”) in the card list. The “browser appearance” option allows you to define a custom template to be used only in the browser, so you can include only the important fields and change the order if you desire. The syntax is the same as in standard card templates. When using this option, if the text in the question column is repeated at the beginning of the answer column, Anki will display the text only in the question column. For example, if the question column text is “People in Ladakh speak”, and the answer is “People in Ladakh speak Ladakhi”, the answer column will only display “Ladakhi”, omitting the rest.Platform-Specific CSS
Anki defines some special CSS classes that allow you to define different styling for different platforms. The example below shows how to vary the font depending on where you’re reviewing:Installing Fonts
You can install fonts directly to Anki. This is useful if you’re using Anki on a work or school computer where you don’t have permission to install new fonts, or if you’re using Anki on a mobile device. Anki supports the most widely used font formats, such as TrueType (.ttf), OpenType (.otf), Web Open Font Format (.woff) and others.Add Font to Media Folder
Once you have downloaded a supported font, such as “Arial.ttf”, you have to add it to the media folder.- Rename the file, adding an underscore at the start, so it becomes like “_arial.ttf”. Adding an underscore will tell Anki that this file will be used on a template, and should not be deleted when checking for unused media.
- In your computer’s file browser, go to your Anki application data folder (see File Locations for details),
- Inside the folder, you should see a folder called collection.media. Drag the renamed file to that folder.
Update Template to Use That Font
After the font has been added to the media folder, you need to update the template.- Click Add at the top of the main screen, and then select the note type you want to change with the top left button.
- Click Cards.
- In the styling section, add the following text to the bottom (after the last ”}” character), replacing “_arial.ttf” with the name of the file you copied into your media folder: