# Horizontally center align block latex

**URL:** <https://forums.ankiweb.net/t/horizontally-center-align-block-latex/48848>\
**Category:** Card Design\
**Created:** [August 31, 2024, 5:57am UTC](https://forums.ankiweb.net/t/horizontally-center-align-block-latex/48848 "2024-08-31T05:57:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jcznk](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/jcznk/32/15215_2.png) [@jcznk](https://forums.ankiweb.net/u/jcznk)\
**Post date:** [August 31, 2024, 7:25am UTC](https://forums.ankiweb.net/t/horizontally-center-align-block-latex/48848/2 "2024-08-31T07:25:10Z")

</div>

This code seems to work well on my end for applying styling specifically to “block LaTeX”:

```auto
.latex[alt*="displaymath"], .latex[alt*="$$"] {
    display: block; 
    margin-left: auto; 
    margin-right: auto;
}

```

Explanation: I checked the HTML and noticed that the `alt` attribute in the LaTeX images contains certain text like `"displaymath"` or `"$$"` when block LaTeX is used. The CSS uses a partial match selector (`[alt*=""]`) to target these cases.

While this worked in my testing, it might not cover every scenario. If needed, you can use this add-on to inspect the `alt` attribute and tweak the selector: [AnkiWeb - AnkiWebView Inspector Add-on](https://ankiweb.net/shared/info/31746032).

---

_[View the full topic](https://forums.ankiweb.net/t/horizontally-center-align-block-latex/48848)._
