views:

177

answers:

6

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?

+11  A: 

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.

Jonathan Sampson
You also won't be wasting bandwidth if you do this.
David
`create a backup` No no, better yet **Use Source Control!!**
Earlz
@David/@Earlz good points.
Jonathan Sampson
but after some time many changes will have done in that page then i can't use backuped page
metal-gear-solid
If source control is not available, simply comment it.
Emad
@Jitendra: Determine whether the individual changes you're making are worth backing up, and then keep versions of them if necessary. Don't go the "easy" route simply because it is less work. Make your clients happy, not numb :)
Jonathan Sampson
+1  A: 

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

It is needed to actually remove something from the page markup when there are security implications. If a user doesn't have the right to see some sensitive information, it shouldn't be there when they click "Display source".

Developer Art
+1  A: 

display: none is good to hide things you want visible when people turn css off or use browsers that doesnt support css.

Filip Ekberg
+2  A: 

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.

Emad
+2  A: 

It's probably also worth mentioning here that some search engines (Google for example) do take stock of hidden content.

Hiding huge amounts of text using display:none; is one of the things many search engines pick up on as keyword spamming.

:)

Jamie Dixon
A: 

As far as accessibility goes, there is a strong chance that something hidden with "display: none;" will NOT be read by a screen-reader. This may be acceptable if you intend for it to be that way.

A possible alternative to hiding content for screen-readers/css-offers only 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 full information on hiding techniques: http://www.access-matters.com/2005/04/23/screen-reader-test-results/

medigerati