Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why use a:link instead of simply a?

    I submit that, since you can link to ids, the use of <a> as merely named anchors is unecessary, and thus the :link pseudo-class is superfluous.

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't use it often, but when I do it's because I don't want <a name="howOld">How old are you?</a> to get styled the same as my <a href="#howOld">How old are you?</a> links. That is, I believe :link is the equiv of a[href]. Anchors and actual clickable links can be styled differently this way (and is often useful, as in the case of a FAQ)

    And as for linking to IDs, do all browsers support that yet? Its probably there for backward-compatibility.
    Last edited by AaronW; 09-25-2004 at 12:07 PM.

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Location
    engoku no anime
    Posts
    354
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I agree with Aaron. If you want unusable anchors to have a different color (among other things) than usable (link) anchors, it is very useful to use a:link. I am working on a page for a friend, and I used a to define a global effect for all of my anchors and a:link to define an effect that only applies to link anchors. It necessary for me to do this because...well, just look at my code:

    Code:
    /* CSS */
    
    li a {
    background-color: #099;
    margin: 0;
    height: 100%;
    padding: 0 0 0 4%;
    display: block;
    font-weight: bold;
    }
    
    a {
    text-decoration: none;
    }
    
    a:link {
    color: #009;
    }
    
    a:link:hover {
    color: #00f;
    background-color: #0ff;
    }
    
    #active {
    background-color: #f0f;
    }
    
    /* End CSS */
    
    <!-- HTML -->
    
    <ul>
      <li><a id="active">Home</a></li>
      <li><a href="dir.html" title="View the Directions">Directions</a></li>
      <li><a href="gbc.html" title="View GameBoy/GameBoy Color games">GameBoy/GB Color</a></li>
      <li><a href="gba.html" title="View GameBoy Advance games">GameBoy Advance</a></li>
      <li><a href="nes.html" title="View Nintendo/Famicom games">NES/Famicom</a></li>
      <li><a href="snes.html" title="View Super NES/Super Famicom games">SNES/Super Famicom</a></li>
      <li><a href="ggear.html" title="View Game Gear games">Game Gear</a></li>
      <li><a href="genesis.html" title="View Genesis/MegaDrive games">Genesis/MegaDrive</a></li>
      <li><a href="32x.html" title="View 32X games">32X</a></li>
      <li><a href="psx.html" title="View PlayStation games">PlayStation</a></li>
    </ul>
    
    <!-- End HTML -->
    Notice that I defined a global background-color for my nav list using li a. Take note of #active (blue). I needed a different color that showed a user is on that page. Take note of how I applied that in the HTML (blue). One problem left: disallowing a user to see a hover effect when that #active link is rolled over. Simple- Since it isn't a link (isn't a:link), I just combined that: a:link:hover. Problem solved.

    This is one good reason to use it, and it shows that people actually do combine pseudo-classes (for all of you unaware of the possibilities).

  • #4
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ...

    I understand why :link exists... I'm saying... it's unecessary... ya dig?? Yipes...

    Show me a browser that doesn't support it, and let's play a game where we see if any reasonable person should care. It'll be fun, go!

  • #5
    Regular Coder
    Join Date
    Jul 2004
    Location
    engoku no anime
    Posts
    354
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You know why :link exists, yet you feel it is unnecessary? You completely contradicted yourself.

  • #6
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Make that IE4+... though it's mildly interesting to note that my

    a:active {
    position: relative;
    top: -2px;
    }

    hopping-link trick breaks every link in that same browser. Hehe..

    IE3 doesn't seem to support it. Just hops to the top of the page.

    Verdict: meh!

  • #7
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by gohankid77
    You know why :link exists, yet you feel it is unnecessary? You completely contradicted yourself.
    What? Haha... no I don't. You just need it put a different way, apparently...

    "I understand why :link was created(and thus *why it exists*), but I feel it is NOW(omitted because, well, that's what time it is, so I figured we'd all assume that) unecessary."

    ...

    Savvy?

  • #8
    Regular Coder
    Join Date
    Jul 2004
    Location
    engoku no anime
    Posts
    354
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow... I'm surprised anyone other than me still has a browser that old. Well... Not really. I still have NN4.79! I don't use it except to see how horrible a modern CSS-styled page looks. BTW, I propose we stop debating in this thread. After all, someone did start it to get help, not to see members debate because of a simple statement.

  • #9
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts


    ...

    WOW

  • #10
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, HE started the thread. Heh. He didn't want help... I think he just thinks the W3C folks read this board or something?

    Not sure if this is helpful or not:

    http://www.w3.org/TR/REC-CSS2/select...pseudo-classes

    Apparently it was created to distinguish between visited and non-visited links. Even still, a:visited has more specificity than simply "a", so again there's not much point in it other than to satisfy people who like to use the anchor tag as an achor.

  • #11
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's got nothing to do with wanting them to read this! But that's really funny!

    I had this crazy notion that maybe we could all look at reality, and realize that it's superfluous. Or, somebody would come in with a relevant reason for using it, but... nobody has. Named anchors? But... *id linking is widely supported* and *less markup than adding even a simple named anchor* and *makes just as much if not _more_ sense*...

    <a> is on the way out, eventually, anyway... I'm not suggesting the spec be changed, that's a silly suggestion. I thought the obvious suggestion implied is to cease the practice of using this...
    Last edited by ]|V|[agnus; 09-25-2004 at 07:20 PM. Reason: clarification of final point

  • #12
    Regular Coder
    Join Date
    Jul 2004
    Location
    engoku no anime
    Posts
    354
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <a> is on the way out? So what would replace it?

  • #13
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I should say that I'm not certain on that... but I had read that it was planned to be phased out of the markup specs eventually in favor of something like "hlink".

    I'm not sure I guess, but this specific point is really a non-issue in the scope of the whole point.

  • #14
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    XHTML 2 proposes using the <link> tag I think? Not to mention making href an attribute for all rendered elements or something like that.

    <dl>
    <dt href="/home">Go home</dt>
    <dd>This link here would take you home...</dd>
    </dl>

    Will be nice. Hopefully my grandchildren will be able to make use of it before they die.

    Edit: http://www.w3.org/TR/xhtml2/ Oooh what fun.
    Last edited by AaronW; 09-25-2004 at 07:30 PM.

  • #15
    Regular Coder
    Join Date
    Jul 2004
    Location
    engoku no anime
    Posts
    354
    Thanks
    0
    Thanked 0 Times in 0 Posts
    First of all, I apologize for the look of the quote if it turns out badly. It was a copy/paste job.

    1. The definition of the <a href="..."> element in XHTML:

    <hlink namespace="http://www.w3.org/1999/xhtml"
    element="a"
    locator="@href"
    effect="replace"
    actuate="onRequest"
    replacement="@target"/>

    2. Defining <img/> in XHTML

    <hlink namespace="http://www.w3.org/1999/xhtml"
    element="img"
    locator="@src"
    effect="embed"
    actuate="onLoad"
    onFailure="warn"/>
    <hlink namespace="http://www.w3.org/1999/xhtml"
    element="img"
    locator="@longdesc"
    effect="new"
    actuate="onRequestSecondary"/>
    <hlink namespace="http://www.w3.org/1999/xhtml"
    element="img"
    locator="@usemap"
    effect="map"
    actuate="onLoad"/>

    3. Defining <object> in XHTML

    <hlink namespace="http://www.w3.org/1999/xhtml"
    element="object"
    locator="@data"
    effect="embed"
    actuate="onLoad"
    onFailure="processChildren"
    onSuccess="ignoreChildren"/>

    4. Defining a new <home/> element

    <hlink namespace="http://www.example.com/markup"
    element="home"
    locator="/"
    effect="replace"
    actuate="onRequest"/>
    <hlink namespace="http://www.example.com/markup"
    element="home"
    locator="/icons/home.png"
    effect="embed"
    actuate="onLoad"/>

    In the context of this definition, and the namespace declaration

    xmlns="http://www.example.com/markup"

    the markup

    <home/>

    will display a clickable icon that takes the user to the home page.
    5. Defining redirection:

    <hlink namespace="http://www.example.com/markup"
    element="redirect"
    locator="@href"
    effect="replace"
    actuate="onLoad"/>

    In the context of this definition and a suitable namespace declaration, the following markup will cause the initiating resource to be redirected:

    <redirect href="whereever">This page has moved</redirect>

    6. Defining <html:blockquote>

    <hlink namespace="http://www.w3.org/1999/xhtml"
    element="blockquote"
    locator="@cite"
    effect="new"
    actuate="onRequestSecondary"/>

    7. Defining RDF

    <hlink namespace="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    element="Description"
    locator="about"
    effect="new"
    actuate="onRequestSecondary"/>
    <hlink namespace="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    locator="resource"
    effect="new"
    actuate="onRequestSecondary"/>

    - From http://www.w3.org/TR/hlink/#s_examples
    Nice one, Aaron. Hmm... This'll be a bit harder to get used to... No wonder it won't be backward-compatible.

    <!-- Edit -->

    <a> hasn't been eliminated yet: http://www.w3.org/TR/xhtml2/mod-hype...ypertextmodule


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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