To hide an element in CSS, you may use:
The difference is that:
They are used has the basic elements to implement toggling
Example:
.hidden {
/* Not displayed at first */
display: none;
}
<button>Toggle</button>
<p class="toggle hidden">I'm not visible until you click on the button</p>
document.querySelector("button").addEventListener("click",function(){
document.querySelector(".toggle").classList.toggle('hidden');
});