Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it ok to hide any things using display:none?

Is it ok to hide any thing temporarily or forever using display:none? in dynamic site where many component of page coming from different plugins etc and many time if client doesn't want any thing on page then i use dispaly:none to hide things from page . I do not remove thing from actual source because client can come back ask to enable that thing again.

so what are pros and cons to keep things hide from display:none if i keep any element hide using Display:none forever?

is there any cons in terms of SEO, Screen reader, Accessibility etc?

like image 226
Jitendra Vyas Avatar asked Nov 30 '22 11:11

Jitendra Vyas


2 Answers

If the client wants it removed, then create a backup of the page, and post a page that actually has it removed. Don't substitute CSS for actually removing an item. If they decide they want it in the future, then go in and swap your backup for your live copy. If you're dealing with dynamic output (in the case of PHP or a comparable technology) you could stop that particular output with comments so they're never included in the response.

like image 169
Sampson Avatar answered Dec 04 '22 06:12

Sampson


Pros: Very easy to do

Cons:

  • You are still loading the components on the server side and the client will download them. The browser will simply not "show" them.
  • Anyone using "view source" will be able to see the values that are "hidden". so never use it to hide sensitive information.

You can simply "comment" these section server side to save a lot of processing on the server, bandwidth, etc.

like image 22
Emad Gabriel Avatar answered Dec 04 '22 06:12

Emad Gabriel