Can I hide any things with the display: no?

Is it possible to hide any thing temporarily or permanently with display:none ? in a dynamic site where many page components come from different plugins, etc. and many times if the client does not want anything on the page, I use dispaly:none to hide objects from the page. I do not delete the thing from the real source, because the client can go back to enable this thing again.

so for the pros and cons keep things hidden from display: no, if I keep the hidden element with display:none forever?

Are there any disadvantages in terms of SEO, screen reading, accessibility, etc.?

+4
source share
6 answers

Pros: Very easy to do

Minuses:

  • You are still downloading components from the server side and the client is downloading them. The browser simply will not "show" them.
  • Anyone who uses a "view source" will be able to see values ​​that are "hidden." therefore, never use it to hide sensitive information.

You can simply β€œcomment” on this part of the server server to save most of the processing on the server, throughput, etc.

+4
source

If the client wants to delete it, back up the page and publish the page on which it was deleted. Do not substitute CSS for the actual removal of the element. If they decide they want it in the future, then go in and replace your backup with your live copy. If you are dealing with dynamic output (in the case of PHP or comparable technology), you can stop this output with comments so that they are never included in the response.

+12
source

It is probably worth mentioning that some search engines (e.g. Google) use hidden content.

Hiding a huge amount of text with display:none; - This is one of those things that many search engines use to send keywords.

:)

+2
source

It makes sense to hide / show stuff with "display: none" when you do client-side Ajax. This way you can switch views / tabs without having to make the server round-trip.

You really need to remove something from the page layout when there are security implications. If the user does not have the right to see any confidential information, he should not be present when they click "Display Source".

+1
source

display: none is useful to hide what you want to see when people turn off css or use browsers that don't support css.

+1
source

Regarding accessibility, there is a high probability that something is hidden with "display: none"; Will NOT be read by a screen reader. This may be acceptable if you intend to be so.

A possible alternative to hiding content for screen readers / css sentences is to use this class:

 .offscreen { position: absolute; left: -9000px; width: 0; overflow: hidden; } 

And the following HTML:

 <h3 class="offscreen">Site Navigation</h3> 

For complete information on hiding methods: http://www.access-matters.com/2005/04/23/screen-reader-test-results/

0
source

Source: https://habr.com/ru/post/1301710/


All Articles