...

View Full Version : Why use a:link instead of simply a?



]|V|[agnus
09-25-2004, 10:34 AM
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.

AaronW
09-25-2004, 01:04 PM
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.

gohankid77
09-25-2004, 05:28 PM
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:



/* 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).

]|V|[agnus
09-25-2004, 07:42 PM
...

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!

gohankid77
09-25-2004, 07:54 PM
You know why :link exists, yet you feel it is unnecessary? You completely contradicted yourself.

]|V|[agnus
09-25-2004, 07:56 PM
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!

]|V|[agnus
09-25-2004, 07:58 PM
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?

gohankid77
09-25-2004, 08:01 PM
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.

]|V|[agnus
09-25-2004, 08:04 PM
:eek:

...

WOW

AaronW
09-25-2004, 08:11 PM
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/selector.html#link-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.

]|V|[agnus
09-25-2004, 08:16 PM
It's got nothing to do with wanting them to read this! But that's really funny! :rolleyes:

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...

gohankid77
09-25-2004, 08:19 PM
<a> is on the way out? So what would replace it?

]|V|[agnus
09-25-2004, 08:23 PM
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.

AaronW
09-25-2004, 08:23 PM
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.

gohankid77
09-25-2004, 08:32 PM
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-hypertext.html#s_hypertextmodule

AaronW
09-25-2004, 08:34 PM
http://www.w3.org/TR/xhtml2/mod-edit.html#s_editmodule

Ha. Get a load of that. You'll flip, knowing how much you hate the idea of superfluous markup... Bunches of content set to display: none, in the name of semantics. Hehe.

Alright. We're off topic. Or are we? I want a "cool things to come" thread.

I feel like I'm high on sugar or something... All I've eaten is a wee bag of like 10 Ritz cheeze sandwiches. *reads ingredients*

gohankid77
09-25-2004, 08:37 PM
So create it! That would be awesome! A discussion on things to come! What a grand idea!

Technically, this isn't off-topic since the thread was created to be informative.

gohankid77
09-25-2004, 08:40 PM
Check this out! Server-side languages are becoming more useless everyday:

http://www.w3.org/TR/xhtml2/mod-hyperAttributes.html#col_Hypertext

See the hreftype attribute? For file upload restrictions maybe?

AaronW
09-25-2004, 08:49 PM
<input type="file" accept="image/jpeg" /> is valid today, but I've yet to encounter a UA that supports it. Friggin' annoying.

gohankid77
09-25-2004, 08:56 PM
The difference is that it will be available to all elements. I read further into that section:

<img src="logo" hreftype="image/png, image/jpeg" />

That searches for a filename of "logo" with a PNG extension (logo.png) and then with a JPEG/JPG extension (logo.jpeg/logo.jpg). Nifty. They applied it to the <p> element, though... I wonder what that does...

<!-- Edit -->

Looks like they are bringing back the "target" attribute.

http://www.w3.org/TR/xhtml2/mod-hyperAttributes.html#adef_hyperAttributes_target

gohankid77
09-25-2004, 09:40 PM
Let's create a new thread! I just saw the new <nl> element in XHTML2! No more <ul><li><a href=""></a></li></ul>! Just <nl><label></label><li href=""></li></nl>! Check it out here: http://www.w3.org/TR/xhtml2/mod-list.html#edef_list_nl

<!-- Edit -->

]|V|[agnus was right:



Even though this means that the a element is now strictly-speaking unnecessary, it has been retained.


That is from the XHTML 2.0 Introduction page under the linking section. Since any element can have an href attribute, the a is technically unnecessary. Yay for the W3C!

<!-- Edit (again!? LOL) -->

http://www.w3.org/TR/xhtml2/xhtml2-doctype.html has a list of XHTML 2.0 modules.

This is getting quite exciting, despite the complexity. Instead of HTML events, XMLEvents are used. Instead of HTML frames, XFrames are used. Client-side scripting is becoming useless (I learned that little bit of JavaScript for nothing! Well, it WAS 5 minutes...) Metadata and Metainformation is changing. <br/> is becoming <l></l> (those are L's). Forms are being switched to XForms.

In other words, lots of changes are going to occur, so start learning now. Remember to keep an open mind as these are all part of the present XHTML 2.0 Working Draft, not the future XHTML 2.0 Recommendation (yet).

mindlessLemming
09-26-2004, 12:49 AM
I've been refraining from saying this....
I agree with Magnus
(wow, that wasn't so hard :p ;))

As for XHTML 2 - there's lots of cool stuff :cool:
My favourites are these:


nextfocus = IDREF
This attribute specifies an IDREF of an element in the current document that will receive focus when the user requests that user agent navigate to the next element that can receive focus.
...
Regardless of the way in which an element receives focus, if the element is not currently visible on the user agent's display, the display must be updated so that the element is visible.

There's also a prevfocus version...
This could be a great solution to hiding 'accessibility' menus (skip to content etc.) - When they receive focus, they must - according to the spec - be visible.



access = QName
A user agent should allow the user to access the user agent's list of recognized access points, to add to them, and to specify bindings for them.


Hooray! Good bye accesskeys - hello predefined access points that are assigned to keystrokes by the user! :thumbsup:
No more 'Accesskeys do more harm than good' issues :D

gohankid77
09-26-2004, 01:56 AM
IMO, XFrames, XForms, and tables will be the hardest to learn (XFrames look really fun *sarcasm*). Here is my ranking of the three from easiest to hardest:


Tables
XForms
XFrames


XFrames... Confusing... I wonder how an author uses them in an XHTML document....

/* Edit */

Just found out: an author doesn't use them in an XHTML document (unless the XHTML document was generated via XSLT). At least, I think so anyway. I am unsure.

gwendaal
09-26-2004, 09:37 AM
it is really over my head .. who cares for IE4 and N4.7 ??

gohankid77
09-26-2004, 06:06 PM
Some people do. I rarely use NN4.7 due to a forum member's request. I mainly use it to see what kinds of things are messed up in modern CSS-styled Web pages. It can be quite amusing.

gsnedders
09-26-2004, 06:08 PM
it is really over my head .. who cares for IE4 and N4.7 ??

Not me... but I care about Lynx, at least you don't get any mucked up style, you just get text.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum