# The style element is lost after click the "HTML Editor"

**URL:** <https://forums.ankiweb.net/t/the-style-element-is-lost-after-click-the-html-editor/19370>\
**Category:** Help\
**Created:** [April 24, 2022, 10:14am UTC](https://forums.ankiweb.net/t/the-style-element-is-lost-after-click-the-html-editor/19370 "2022-04-24T10:14:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kellen](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@Kellen](https://forums.ankiweb.net/u/Kellen)\
**Post date:** [April 24, 2022, 10:14am UTC](https://forums.ankiweb.net/t/the-style-element-is-lost-after-click-the-html-editor/19370/1 "2022-04-24T10:14:34Z")

</div>

![style-lost](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/1/12b360649638f592698202d1409cc8263850ae57.gif)

OS: Windows 11  
Anki-desktop: 2.1.49(dc80804a)  
Anki-desktop: 2.1.50 with qt6

When I use the “HTML Editor” function in 2.1.49, the “\<style\>…\</style\>” element is deleted after editing.

The style element is deleted even I never use the “HTML Editor” in 2.1.50.

---

<div class="post-metadata">

**Author:** ![kleinerpirat](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/kleinerpirat/32/19863_2.png) [@kleinerpirat](https://forums.ankiweb.net/u/kleinerpirat)\
**Post date:** [April 24, 2022, 12:46pm UTC](https://forums.ankiweb.net/t/the-style-element-is-lost-after-click-the-html-editor/19370/2 "2022-04-24T12:46:09Z")

</div>

I think CodeMirror (the JS library for the new HTML editor) strips `<style>` tags by default and this behavior was kept intentionally. Styles belong in the CSS section of your note template.

If you want to apply CSS to the field contents in the editor, you could use my add-on [CSS Injector - Change default editor styles - AnkiWeb](https://ankiweb.net/shared/info/181103283).

---

<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:** [May 1, 2023, 4:23am UTC](https://forums.ankiweb.net/t/the-style-element-is-lost-after-click-the-html-editor/19370/3 "2023-05-01T04:23:57Z")

</div>

Closed on May 1, 2023, 4:23am UTC


