SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inline style for <a> tag?

    Is this even possible? I'm trying to implement an inline style attribute for a link. This is the way I have coded it initially, but it does not work. Can anyone help me understand what to do?
    PHP Code:
    <a style="link{color: #'.$linkColor.';
                                    text-decoration: none;}
                               hover{color: #'.
    $hoverColor.';
                                    text-decoration: underline;}
                               visited{color: #'.
    $vLinkColor.';
                                    text-decoration: none;}"
                               
    href="#top">Your Links</a
    John

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2000
    Location
    Chico, Ca
    Posts
    1,125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure, what you are asking?

    If I understand your post you want links to run horizontal ?

    Have you looked at link lists ?

    I saw something a while back about how to do that ..
    "Happiness doesn't find you, you find happiness" -- Unknown
    www.chuckknows.com

  3. #3
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, this is one link. I am trying to set the color and text decoration for this one link.

    What I am using it for is a configuration script that dynamically sets the colors for all the site's links. This one link is being used as a preview link to see what it would look like once the colors go site-wide.

    In order to do this preview, I need to set the link's attributes in line, and I need to know how to do this, or even if it is possible.
    John

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2000
    Location
    Chico, Ca
    Posts
    1,125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you talking about something like this color selector

    This one is pretty cool also:

    colorschemer
    "Happiness doesn't find you, you find happiness" -- Unknown
    www.chuckknows.com

  5. #5
    SitePoint Evangelist S7even's Avatar
    Join Date
    Jun 2002
    Posts
    481
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    John, I don't think thats possible. You can define inline style for elements, so you could define an inline style for a , but link, visited and hover are pseudo elements, so i don't think you can define those inline.

    You can add the style to the a element, and then simulate hover using javascript.
    Something like:
    Code:
    <a href="#" style="color:blue; text-decoration:none;" onmouseover="this.style.color='red'" onmouseout="this.style.color='blue'">Hello</a>

  6. #6
    SitePoint Member byss's Avatar
    Join Date
    Sep 2002
    Location
    Central Kentucky, USA
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    you could do it page-wide as inline

    Insert the code below in your <head> section.


    Code:
    <style>
    <!--
    a {
       color: #LINKCOLOR;
       text-decoration: none; }
    a:hover {
       color: #HOVERCOLOR;
       text-decoration: underline; }
    a:visited {
       color: #VISITEDCOLOR;
       text-decoration: none; }
    
    
    -->
    </style>

    A stands for the anchor tag <a> which you use to make a link, and then you use a:hover and a:visitied to tell it you mean anchor tags that are hovered over or have been clicked on, respectively. You can also even use the a:active for links, but it's rather useless. It's for links that have been mouse clicked down on, but the button wasn't released on the link (making it change color without actually following the link--like I said, rather useless).

    This will affect the entire page's links, not just one link. But that should work for you, as most times you want consistent links for the whole page (if not the whole site).

    Caution: Slow Children At Play -->

  7. #7
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    You can't define pseudo-classes like :hover and :active inline. This can only be set in a separate CSS file or in the <head> of your document.

  8. #8
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, guys! That's was a big help.

    After reading all of your responses, I ended up creating a dynamicly built css file in which I defined a class just for that one link.

    Thanks again!
    John


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •