The !important key should only be used as a temporary solution. It is generally a last resort in urgent situations and when overriding external CSS libraries. You can use document.querySelector(".element").style.display = "flex"; to apply a display style, and override it later with document.querySelector(".element").style.display = "none";
To ensure clear and manageable CSS, it is best practice to add, remove, or override the same classes instead of directly applying inline styles.