define style sheet within style attribute of anchor tag

Discussion in 'CSS' started by Ankit, Jan 29, 2009.

  1. #1
    How can I define style sheet within style attribute of anchor tag with active, hover, visited?

    I don’t want to define external css styleseet or in page head tag.

    LIKE

    <A HREF="/test.html" STYLE=".....WANT TO DEFINE HERE......"> Test Link</A>

    Please help.
     
    Ankit, Jan 29, 2009 IP
  2. A12Alex

    A12Alex Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why not...? lol..
     
    A12Alex, Jan 30, 2009 IP
  3. My220x

    My220x Member

    Messages:
    624
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    35
    #3
    You can't use CSS pseudoclasses in inline link styles, you would have to use embedded CSS or external CSS.
     
    My220x, Jan 30, 2009 IP
  4. Ankit

    Ankit Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think some solution must be exist for this
     
    Ankit, Feb 3, 2009 IP
  5. My220x

    My220x Member

    Messages:
    624
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    35
    #5
    You can't do it with inline styles the CSS spec doesn't allow it the only way would be embedded CSS or external CSS. Now if you wanted to apply the CSS to only one link element on each page then add the "id" attribute to the opening anchor tag and in your embedded/external CSS put:

    
    #nameofid a:link {
    color: red;
    }
    
    #nameofid a:visited {
    color: green;
    }
    
    Code (markup):
    If you wanted to apply the style to multiple links then use the "class" attribute and replace the # in your CSS with a .
     
    My220x, Feb 3, 2009 IP