Re: [selectors] New pseudo-class proposal: ":current"

Alastair Campbell wrote:
> Matthew Raymond wrote:
>> you'll want to
>> indicate which link points to the current page. 
> 
> I'd rather this was not used, partly because it promotes what I consider 
> bad practice:
> http://alistapart.com/articles/whereami
> The bit that talks about: "Never, ever link to the page you’re on". [1]

   The main argument there is that the user expects the link to take
them to a different page, whereas linking to the page you're on doesn't
do that. This really isn't an argument against :current because the
pseudo-class allows you to style such links in a manner that allows
people to identify that the link is to the current page. In fact,
:current can be used for debugging purposes to catch unintentional
self-referencing links, or to remove them altogether:

| a:current { display: none; }

   When combined with XBL, the hyperlink itself can be replaced with
static text.

> 
> To get the same or similar effect for the current page, I would use a 
> strong (or span) for the current page instead of a link.
> 
[Snipped the exceedingly obvious example.]
> 
> The advantage of :current would be that you don't need to change the 
> markup, however, I think there are a few situation where it wouldn't 
> work that would be confusing for the user. E.g. when within page links 
> are used (e.g. http://example.com/page.html#content),

   Actually, in those situations you could use :current in combination
with :target to simulate tabs.

   As for situations where you have a hyperlink pointing to the base URL
(http://example.com/page.html), and the URL has an anchor in it
(http://example.com/page.html#content), you could simply have base URL
hyperlinks always match regardless of the anchor. Only when the
hyperlink itself points to an anchor does it have to match the whole URL.

   Alternatively, :current could take an argument:

| :current(base) { /* Markup for base URL links. */ }
| :current { /* Markup for complete URL. */ }

> and Daniel's
> point. (I think there may be other situations?)

Daniel Glazman wrote:
> Won't work for redirections, and all servers manipulating the incoming
> URL one way or another.

   In the former situation, why would you have a link that redirects to
the current page? I don't think it's unreasonable to require websites to
have self-referencing links that are discoverable with little or no
effort by the UA. After all, why would you want a link where the user
has no way of knowing that it refers to the current page, even if they
examine the URL?!?

   For the latter, the server manipulating the URL would have to do so
in a way that would prevent user agents from identifying a matching URL,
and would furthermore have to do so in a way that the altered URLs
wouldn't match. That seems to be an edge case not worth worrying about.

> Just have a site home page www.example.com automapping to
> www.example.com/index.html. Linking "/" will not trigger that
> pseudoclass...

   I'm not sure what you mean here, but you demonstrate a simple method
by which user agents could discover self-referencing hyperlinks in some
situations.

Alastair Campbell wrote:
> Given it would not work consistently, you would probably find you 
> wouldn't want to use it for usability reasons.

   It has uses even when it would not work consistently, but I suspect
that most sites that use it as an important part of their styling would
take reasonable care with their URLs anyways. Besides, the expense of
implementation isn't significant, so why would it be so important if it
doesn't work well in specific edge cases?

Received on Friday, 13 October 2006 17:14:56 UTC