:target pseudo-class : Pseudo Class « Style Basics « HTML / CSS






:target pseudo-class

  

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title> Albert Einstein </title>
        <style type='text/css' media='all'>
            div#quoteimage:target {
                background-color: black;
                border: 1px solid white;
            }
            h1#top:target {
                background-color: black;
                border: 1px solid white;
                color: white;
            }
            h1 a {
                color: inherit;
                text-decoration: none;
            }

            div#quoteimage {
                margin: 10px;
                text-align: center;
            }
            img#albert {
                width: 305px;
                height: 240px;
                border: 5px solid black;
                margin: 10px;
            }
        </style>
    </head>
    <body>
        <div></div>
        <div>
            <h1>Famous Quotes</h1>
            <h1 id='top'><a href='#quoteimage'>Albert Einstein</a></h1>
        </div>
        <div></div>
        <ul>
            <li><a href='http://www.google.com'>Google</a></li>
            <li><a href='http://p2p.wrox.com'>Wrox P2P</a></li>
            <li><a href='http://www.mozilla.org'>Mozilla</a></li>
            <li><a href='http://pear.php.net'>PEAR</a></li>
        </ul>
        <div>
            <p>
              This is a test. This is a test. 
            </p>
        </div>
        <div></div>
        <div id='quoteimage'>
            <a href='#top'><img src='http://www.java2s.com/style/logo.png' id='albert' /></a>
        </div>
    </body>
</html>

   
  








Related examples in the same category

1.The first-child Structural Pseudo-Class
2.Dynamic Pseudo-Class Selectors
3.first-letter and :first-line Pseudo-Elements
4.Dynamic pseudo-classes
5.Structural pseudo-classes
6.h1::before, h1::after content: "::";
7.The first-child pseudo-class
8.Using the first-letter pseudo-element to create a "drop cap" letter
9.Link Pseudo-Class Example
10.:before and :after Pseudo-elements
11.Use Pseudo-Classes
12.First-letter Pseudo-element
13.Creating a drop cap using a CSS pseudo-element
14.First Line and Letter
15.p:first-line{font-weight:bold;}
16.first-letter {font-size:42px; width:200px;}
17.tr:first-child
18.Set style for a:link and a:visited