There are multiple ways to make an element not visible to the user. The following are top three of those.
hidden
1 | <span hidden> |
One can still see this by inspecting the page using developer tools.
display: none
This is the CSS version of hidden attribute.
1 | <span id="secret"> |
1 | #tribute { |
Trivia: When we set the
hiddenattribute, the browser actually sets thedisplay: none;to the respective element. Check it yourself ^_^!
visibility: hidden
This does the same thing. But, there are some significant differences between visibility and display CSS properties.
1 | #tribute { |
Tip: Use
displayoption when you do not want the elements to be rendered and usevisibilityoption when you do not want to mess up the layout while hiding elements.\O/