W3C home > Mailing lists > Public > public-css-archive@w3.org > November 2017

[csswg-drafts] [selectors] Match local links

From: Lea Verou via GitHub <sysbot+gh@w3.org>
Date: Sat, 25 Nov 2017 02:43:29 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-276720303-1511577808-sysbot+gh@w3.org>
LeaVerou has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors] Match local links ==
In navigation menus, tables of contents etc there's often a need to highlight the links that point to the current page or a part thereof.
While this is needed in almost every website, it currently cannot be done without JS, server-side coding, or [horrible hacks](https://stackoverflow.com/a/26126610/90826).
Selectors4 used to define a [`:local-link` pseudo-class](https://www.w3.org/TR/2013/WD-selectors4-20130502/#local-pseudo) to solve this issue, but was removed in the latest ED due to lack of interest. IMO that was a good decision, as it was overcomplicated and didn't even cover all common use cases. For example, it ignored fragment identifiers, so it was useless for intra-page navigation.

What about a `:local-link` pseudo-class that works like the following:

1. If the link target does not match the current document URL ignoring any fragment identifiers, the pseudo-class does **not** match.
2. If the link target contains a fragment identifier, the fragment identifier must match that of the current document URL, otherwise the pseudo-class does not match. If the link target does not contain a fragment identifier, step 1 is sufficient.

This definition works for both intra-page navigation as well as navigation across pages, and doesn't have all the path segment complexity of `:local-link()`. Furthermore, authors don't have to think what kind of matching they need — it just works.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2010 using your GitHub account
Received on Saturday, 25 November 2017 02:43:34 UTC

This archive was generated by hypermail 2.3.1 : Saturday, 25 November 2017 02:43:39 UTC