When it comes to hiding elements on a web page, there are different ways to achieve the desired result. One commonly used method is to use both the CSS visibility property with a value of hidden and the HTML hidden attribute. While both serve the purpose of hiding an element from view, there is a subtle difference between them. When using the CSS visibility property with hidden value, the element still retains its area in the document, including its height and width. On the other hand, the hidden attribute in HTML behaves similarly to setting the CSS display property to none, where the element no longer takes up space in the DOM. To illustrate this point, consider the following example:
<p style="visibility:hidden">Hello how are you?</p>
<p hidden>I am fine.</p>
If you inspect these elements in your browser, you will see that both paragraphs appear invisible, but the first paragraph element still maintains its area within the document.