Color transition not working with setTimeout. Element should appear smoothy [duplicate]
Color transition not working with setTimeout. Element should appear smoothy [duplicate] This question already has an answer here: Color transition works, if I don't hide the element and then make it appear. const name = document.querySelector(".name"); setTimeout(() => { name.classList.remove("hide"); name.classList.add("color-blue") // name.style.color = "blue"; }, 2000) .name { background-color: orange; display: inline-block; padding: 5px; transition: color 10s; color: transparent; } .color-blue { color: blue; } .hide { display: none } <div class="name hide"> Lebron James </div> If I don't use the class hide and I don't remove it later, the transition works. By hiding it, it does not work. No clue what's going on Thanks for your help This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. ...