Mobile Friendly Website


Doing it with style

CSS DEMOSCSSplay - :target Gallery with no 'history'

Date : Pre 2004

For all modern browsers

This demo is too wide for your mobile screen.
Please view on a tablet or PC.


A revamp of the previous gallery to use :target to keep the selected images on screen even when clicking elsewhere on the page.

This also has a small javascript routine to keep the browser history location on the page entry url so that when using the 'back' button you do not cycle back through the images.

Several people have asked if this is possible, so here is one answer to thequestion.

This fully works in Firefox, Chrome and Safari and parially works in IE9+ and Opera.

The code and stylesheet for this demo are both very simple and show how the normal jump to the top of the browser window is removed by having the :target elements with display:none; and then using the general sibling selector to 'target' the images and resize/repositon them.

So now we have :target with no jump and no browser 'back' button problems.

Because of all the time and effort spent in producing this demonstration I would ask that you respect my copyright.

  1. If you are using this on a personal web site then please retain the copyright comment in the stylesheet.
    A support donation is now required for this demonstration.
  2. If you are using this on a commercial web site, or as a paying job for a client, then please email me asking for permission - stu{at} and again a support donation is required.
  3. If you are having problems integrating any of my demonstrations into your website then I now offer a service to fault find and correct any errors that you may have introduced. Please email me for more information.


Your donations keep CSS PLAY running.
If your donation is for the use of a demo then please email me with the demo url after making your donation.


Facebook Twitter rss feed Facebook Fan Page