Cards render with inconsistent font sizes in AnkiDroid depending on whether the HTML content starts with a <div> tag or not.
Steps to reproduce:
-
Create two cards with identical CSS styling:
-
Card A:
<div><b>Text</b> content here</div> -
Card B:
<b>Text</b> content here
-
-
View both cards in AnkiDroid
Expected behavior: Both cards should render with the same font size since they use the same CSS.
Actual behavior: Card A (with div wrapper) renders with larger text than Card B (without div wrapper).
Environment:
-
AnkiDroid version: [your version]
-
Android version: [your version]
-
Device: [your device]
What I’ve tried (none worked):
-
CSS
font-sizewith!important -
JavaScript to force font size after render
-
CSS
display: contentson divs -
CSS
::beforepseudo-elements -
Viewport units (vw)
-
text-size-adjust: 100%
The issue appears to be in how the WebView calculates initial font metrics based on HTML structure before CSS is applied. Cards starting with block-level elements (<div>) get different base sizing than cards starting with inline elements (<b>, text).
The only workaround is to normalize all card content to either all have div wrappers or none - but this requires database modification and can break intentional line breaks.