Description

The :target pseudo class allows us to select an element on the page that has been targeted in the URL.
The element can be any element with an id: <div id="preview"> or name anchor like: or <a name="preview" ></a> and should be unique on the page.
The target of a url is the part after the '#' symbol eg. 'preview' in this url: http://csscreator.com/content/target#preview
Loading a page with an anchor takes you to that part of the page.

Example

if the url is you are at was: http://csscreator.com/content/target#preview

div:target{ 
  border:solid red medium;
}

<div id="preview"> Preview would have a red border</div>

See: http://thoughtfulviewfinder.in/using-css3-for-lightbox-like-image-display/# for an example of a lightbox using :target

Introduced in CSS version
3
Inherited
N/A
Browser Support
BrowsersIEFirefoxSafariOperaChrome
Versionsnone1.03.19.52.0
Belongs to:

See the full list CSS properties and browser support: CSS Properties