CSS3 has a handy little trick that allows you hide any HTML element by applying the display property. By setting display: none to any HTML element, the element will no longer appear on the viewport, and though the HTML will still appear in the source code, there will be no space left for where the element should appear. Using display: none will completely hide any element so that there’s no visible trace of it except for in the source code.
Here’s how it works. Let’s say you want to hide a certain element with the class “.hideMe”:
- display: none;
That’s all it takes! Just be sure to not overuse the display: none property. In many circumstances it isn’t considered a CSS best practice, and it’s also not always appreciated by search engines like Google if it appears in your CSS too often — but it’s great to use sparingly and if you need to hide something in a pinch!