Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is :target selector ?

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 513
    Comment on it

    The :target pseudo-class represents a unique element, with an id matching the fragment identifier of the URL of the document..

    For example, the URL http://website-path#demo contains the fragment identifier #demo. In HTML, identifiers are found as the values of either id or name attributes, since they two share the same namespace. Thus, the example URL would point to the heading "demo" in this document. - MDN

    Its a very powerful and useful pseudo-class you can use it as tabbed menu, multi popup etc.

    Example :-

    CSS -

    :target {color: red;border: 1px solid #ccc;}
    

    HTML -

    <p id="one">Section ONE</p>
    <p id="two">Section TWo</p>
    <p id="three">Section Three</p>
    
    <a href="#one">First</a>
    <a href="#two">Second</a>
    <a href="#three">Third</a>
    

    Output -

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: