# I can't remove margin from card

**URL:** <https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325>\
**Category:** Card Design\
**Created:** [September 12, 2024, 6:14am UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325 "2024-09-12T06:14:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![LuccasH](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/luccash/32/19331_2.png) [@LuccasH](https://forums.ankiweb.net/u/LuccasH)\
**Post date:** [September 12, 2024, 6:14am UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/1 "2024-09-12T06:14:29Z")

</div>

What is the real **class** or **id** I need to modify to reset the card’s CSS margin?  
_(on all platforms: computer, Anki Droid, etc.)._

I couldn’t identify which class this is. As a stopgap measure, I used Reset CSS, but it’s still not enough for me. Reset CSS is the only one that managed to eliminate the margin of this unknown class.

**I already tried this and it didn’t work:**

```auto
html {
margin: 0 !important;
padding: 0 !important;
}

```

```auto
html body {
   margin: 0 !important;
   padding: 0 !important;
}

```

```auto
.card {
   margin: 0 !important;
   padding: 0 !important;
}

```

**With these codes above, the unwanted result is this:**

 ![01 - PC](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/3X/1/7/175143afbad01c0732495294b42bd8b92baac71a.png)  
 ![01 - AnkiDroid](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/3X/f/4/f4c417233d5240e4564fca4a2d58d3861cf599e5.jpeg)

However, when I applied Reset CSS, I was finally able to reset the margin on both PC and AnkiDroid, but it only works with “!important”. But, applying Reset CSS, there is a problem of removing the margin from all elements, even though the margin property is defined on each element. So I’m forced to put in the margin of other elements “!important” too to fix this. Look:

```auto
* {
	margin: 0 !important;
}

```

```auto
.front {
   margin-top: 50px !important;
}

```

Note that if I don’t apply “!important” to other classes, my text from the “front” field is pasted into the header. **However, the card margin is corrected:**

 ![02 - PC](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/3X/3/f/3f07c37e98f4ea0e5690936da77fd4a8e2e3e2b4.png)  
 ![02 - AnkiDroid](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/3X/2/7/27d72740ceb63201f74adfa87244dddf89605c28.jpeg)

**Full Code Front:**

```auto
<div class="header">
   <h1>Header<h1>
</div>

<div class="front">{{Front}}</div>

```

**Complete CSS Code:**

```auto
* {
	margin: 0 !important;
}

.card {
    font-family: arial;
    font-size: 20px;
    text-align: center;
    color: black;
    background-color: #f9c59c;
}

.header {
   background-color: #373737;
   color: #fff;
   padding: 10px;
}

.front {
		margin-top: 50px !important;
}

```

---

<div class="post-metadata">

**Author:** ![sorata](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/sorata/32/34115_2.png) [@sorata](https://forums.ankiweb.net/u/sorata)\
**Post date:** [September 13, 2024, 4:21am UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/2 "2024-09-13T04:21:51Z")

</div>

what does removing the `<h1>` tags give you? It might be the headers if you didn’t already try changing that.

---

<div class="post-metadata">

**Author:** ![LuccasH](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/luccash/32/19331_2.png) [@LuccasH](https://forums.ankiweb.net/u/LuccasH)\
**Post date:** [September 16, 2024, 12:46am UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/3 "2024-09-16T00:46:27Z")

</div>

My problem doesn’t have to do with the `<h1>` tag, because from the images, you can see that the margin is outside the top `.header` element.

The problem I face is a default margin in the card template itself that forces this margin on all elements and I want to remove it. I was already able to remove this margin in Anki for Windows, but I was unable to remove it in Anki Droid.

I created a script to view the source code of the page on Anki Droid and I already found out which id has this margin applied. It’s the `#content` id.

```auto
#content {
  margin: 0;
}

```

---

<div class="post-metadata">

**Author:** ![dpgrant](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@dpgrant](https://forums.ankiweb.net/u/dpgrant)\
**Post date:** [September 16, 2024, 1:29am UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/4 "2024-09-16T01:29:14Z")

</div>

I use the following CSS to ensure that a background image fills the entire card.

> html, body {margin: 0; height: 100%; overflow: hidden}

I tried adding your header example + css to one of my cards and it seems to accomplish what you’re after.

Of course, YMMV. Good luck.

---

<div class="post-metadata">

**Author:** ![sorata](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/sorata/32/34115_2.png) [@sorata](https://forums.ankiweb.net/u/sorata)\
**Post date:** [September 16, 2024, 5:27am UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/5 "2024-09-16T05:27:47Z")

</div>

Seems like there’s a solution. About the margin, this is apparently done for readability. [[BUG]: Review and Browse have different style · Issue #17058 · ankidroid/Anki-Android · GitHub](https://github.com/ankidroid/Anki-Android/issues/17058#issuecomment-2347384907)

---

<div class="post-metadata">

**Author:** ![LuccasH](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/luccash/32/19331_2.png) [@LuccasH](https://forums.ankiweb.net/u/LuccasH)\
**Post date:** [September 16, 2024, 8:18am UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/6 "2024-09-16T08:18:16Z")

</div>

Have you tested if your code to remove the margin works on Anki for mobile? For me, `html , body {margin: 0;}` only works on desktop, but it doesn’t work on Anki for mobile.

---

<div class="post-metadata">

**Author:** ![LuccasH](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/luccash/32/19331_2.png) [@LuccasH](https://forums.ankiweb.net/u/LuccasH)\
**Post date:** [September 16, 2024, 8:25am UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/7 "2024-09-16T08:25:24Z")

</div>

I opened the link you sent, from what I understand the author of the github issue wants to customize the Anki mobile previewer itself. I just want to customize the card itself. As I said in my previous message, I already found out which **CSS ID** the Anki mobile app uses to automatically apply this margin. And now, I’ve managed to remove it both from the desktop and from Anki Mobile.

---

<div class="post-metadata">

**Author:** ![dpgrant](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@dpgrant](https://forums.ankiweb.net/u/dpgrant)\
**Post date:** [September 16, 2024, 12:52pm UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/8 "2024-09-16T12:52:45Z")

</div>

No I haven’t; I never use mobile. Sorry.

---

<div class="post-metadata">

**Author:** ![dpgrant](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@dpgrant](https://forums.ankiweb.net/u/dpgrant)\
**Post date:** [September 16, 2024, 12:55pm UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/9 "2024-09-16T12:55:01Z")

</div>

Actually, I never use the mobile app. Hmmm.

---

<div class="post-metadata">

**Author:** ![sorata](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/sorata/32/34115_2.png) [@sorata](https://forums.ankiweb.net/u/sorata)\
**Post date:** [September 16, 2024, 12:58pm UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/10 "2024-09-16T12:58:21Z")

</div>

No they are talking about the review screen. Look at Brayan’s comment.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [October 18, 2024, 11:36am UTC](https://forums.ankiweb.net/t/i-cant-remove-margin-from-card/49325/12 "2024-10-18T11:36:55Z")

</div>

Closed on October 18, 2024, 11:36am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
