treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] a:visited Problem/Bug

  • Hello Everyone,
    I'm learning CSS so found this website very useful.
    But while learning I came to a Bug or a Problem don't know why this code is not working :

    <!DO<pre>CTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    a{
    background-color:#0C0;
    padding:6px;
    color:white;
    font-weight:bold;
    font-family:Arial, Helvetica, sans-serif;
    }
    a:link{
    text-decoration:none;
    }
    a:hover{
    background-color:#090;
    text-decoration:underline;
    }
    a:active{
    background-color:#060;
    }
    a:visited{
    color:yellow;
    text-decoration:line-through;
    }
    </style>
    </head>

    <body>
    <a href="#">link</a>
    </body>
    </html>



    I didn't get that why a:visited { text-decoration: line-through or underline is not working ?

    If you can help me then please :)
    Thanks
  • Sorry that I don't have time to dig deeply in to this, but 2 things come to mind:

    1) Long standing advice is to style your link states in this order:
    - Link
    - Visited
    - Hover
    - Focus
    - Active
    (Think Lord Vader's Handle Formerly Anakin)

    2) And I seldom bother styling visited links anymore because some modern browsers have stopped supporting it (out of privacy concerns - unscrupulous folks can target a visited style to capture visitors' browsing history).
  • Ok thanks :)