Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the possible ways to hide an element via CSS [closed]

I am trying to hide an HTML element with CSS.

<select id="tinynav1" class="tinynav tinynav1">

but it's very resilient, even with the Google Inspect element I cannot change the styling.

like image 501
William Avatar asked Oct 16 '13 09:10

William


People also ask

Which CSS property is used to hide an element?

The visibility CSS property shows or hides an element without changing the layout of a document.

Can you hide CSS?

You can't hide the CSS. One way or another it will be downloaded to the browser and most modern browsers have built-in dev tools that let the user inspect the CSS.


1 Answers

It's simple, just set the display property to none in CSS:

#tinynav1
{
  display:none
}

again when you would like to show it set the display to block.

visibility: hidden hides the element, but it still takes up space in the layout.

display: none removes the element completely from the document. It does not take up any space, even though the HTML for it is still in the source code.

Other advantages of using display:

display:none means that the element in question will not appear on the page at all (although you can still interact with it through the DOM). There will be no space allocated for it between the other elements.
visibility:hidden means that unlike display:none, the element is not visible, but space is allocated for it on the page.

like image 121
Vinay Pratap Singh Bhadauria Avatar answered Sep 20 '22 03:09

Vinay Pratap Singh Bhadauria