A live version of anki_style can be seen here: https://tnahs.github.io/anki_style/
anki_style is a standardized style sheet I've developed over the past year or so while using Anki while learning French. It by no means is an exhaustive set of classes for all situations but it covers the basic cards for when learning a language. Namely reviewing: vocabulary, sentences, and conversations. However, most of these classes, if not all, can also be used with any type of card, it's not limited to either languages or specific topics.
The aim was to have a way to flexibly format and re-format my cards. Removing almost all HTML and CSS from Anki ensures that I can change/edit/tweak the color palette or overall theme without having to sift through thousands of cards.
Required:
anki_style.css
Optional: Roboto Slab from Google Fonts
- Copy
anki_style.css
,bullet_sq.gif
andpeek_bg.png
to yourcollections.media
folder.
Note: Make sure to add a leading underscore
_
to the filename. Because the style sheet is not explicitly referenced in any fields, Anki will see it as un-used media whenTools>Check Media
is run. By adding a leading underscore Anki ignores the file when checking media.Thus:
_anki_style.css
,_bullet_sq.gif
and_peek_bg.png
will be in yourcollections.media
folder.
The collections.media
is located:
On Windows, the latest Anki versions store your Anki files in your appdata folder. You can access it by opening the file manager, and typing
%APPDATA%\Anki2
in the location field. Older versions of Anki stored your Anki files in a folder calledAnki
in yourDocuments
folder.On Mac computers, recent Anki versions store all their files in the
~/Library/Application Support/Anki2
folder. The Library folder is hidden by default, but can be revealed in Finder by holding down the option key while clicking on the Go menu. If you’re on an older Anki version, your Anki files will be in yourDocuments/Anki
folder.On Linux, recent Anki versions store your data in
~/.local/share/Anki2
, or$XDG_DATA_HOME/Anki2
if you have set a custom data path. Older versions of Anki stored your files in~/Documents/Anki
or~/Anki
.
- Add
@import 'anki_style.css';
to theStyling
section of your note.
- In the
Front Template
orBack Template
of yourCard Types
window:
- Create a div
<div></div>
- Add a class attribute
<div class=""></div>
- Assign a specific class from the list below.
<div class="box header hcolor"></div>
- Download Roboto Slab and install using the method of your specific OS. https://apps.ankiweb.net/docs/manual.html#installing-fonts
box
:
<div class="box">{{field}}</div>
Using an unordered list:
<ul>
<li>This is how I format...</li>
<li>multiple definitions.</li>
</ul>
Adding type
:
<ul>
<li class=type>This li.type class is used...</li>
<li>as a separator in case...</li>
<li>a word has multiple forms.</li>
<li class=type>noun</li>
<li>noun definition 1</li>
<li>noun definition 2</li>
<li class=type>adjective</li>
<li>adjective definition 1</li>
<li>adjective definition 2</li>
</ul>
question
box:
<div class="box question">{{field}}</div>
For example:
<div class="box question">{{Quesion}}</div>
and a saved search such as:Question:*_*
can be setup to return all cards with something in the{{Quesion}}
field. I find it handy to compile a bunch of questions to ask a native speaker, or do research on at a later time.
peek
box:
<div class="box peek">{{field}}</div>
This takes any box
class and makes the inner text invisible until a hover. It makes cards "three-sided." A sentence translation can be revealed on the back template only after someone has hovered over the box. For example, with a listening card, the back of a card can be revealed to confirm what was heard in the target language without revealing the translation.
pic
box:
<div class="box pic">{{field}}</div>
The pic
class auto-resizes an image to fit within the bounds of the div and styles it to match the rest of the aesthetic.
header
box:
<div class="box header">{{field}}</div>
header
box colored:
<div class="box header hcolor">{{field}}</div>
<div class="box header hgray">{{field}}</div>
This is a purely aesthetic adjustment to the top border color of the header
class.
conversation
box:
<div class="box conversation">{{field}}</div>
This is used only for conversation cards. Fonts are styled smaller along with some minor aesthetic adjustments.
tag
box:
<div class="box tags"># {{field}}</div>
Faintly displays the current tags.
Note: Actual style does not have outline.
hidden
:
Field contents are not rendered on card. Primarily used in two cases. Hide text that's being fed to AwesomeTTS and hide text being fed to a javascript function. In these cases I usually use a <span></span>
instead of a <div></div>
.
<span class="hidden">{{field}}</span>
Note: This first example assumes the use of AwesomeTTS and a group of voices names "FrenchVoices" to generate on-the-fly audio for listening comprehension. See AwesomeTTS Documentation for more on this.
<!-- Front Template -->
<div class="box header hcolor">Écoute:</div>
{{^Audio}}<tts class="hidden" group="FrenchVoices">{{Phrase}}</tts>{{/Audio}}
{{#Audio}}{{Audio}}{{/Audio}}
<!-- Styling (shared between cards) -->
@import '_anki_style.css';
<!-- Back Template -->
<div class="box header hcolor">{{Phrase}}</div>
{{#Anglais}}<div class="box peek">{{Anglais}}</div>{{/Anglais}}
{{#Notes}}<div class="box">{{Notes}}</div>{{/Notes}}
{{#Question!}}<div class="box question">{{Question!}}</div>{{/Question!}}
{{#Tags}}<div class="box tags"># {{Tags}}</div>{{/Tags}}