0
I know that this question can be closed because it is based on opinions but, in order to maintain good practices, follow the scenario below:
1- User made a registration on the site.
2- I display a feedback message and after 5 seconds I hide the message widget.
The doubt is, the right would be to remove the element and insert only when necessary or leave it on the page and just do a toggle to show and hide?
Example of how I use today:
<span style="display:none"> Exemplo feedback </span>
Reinforcing: The most semantic would be to hide and show the element using display
or use the Jquery
to add and remove it?
Thinking semantically you should destroy it, because even with display:One the screen readers will find it, unless you use an Aria-Hidden="true" along with the display:None. I’d let the user himself close the message if it was his wish, like putting an X to close the box or something... But that’s a matter of opinion...
– hugocsl
I agree with @hugocsl. Now semantically speaking, if you have a "warning modal", you can keep it in html, as long as you always use the same, changing only the message that will be displayed, for different purposes, if it is a "default window". Now if only one eventual feedback message appears, and the other warning messages are different (different modal styles), it is better to remove the element. I mentioned modal just to make it clear, it might just be a
span
positioned in for example– Ricardo Pontual