Local hyperlink styling

Tantek complains about how much code my CSS3 rules for styling local and external hyperlinks differently take:

There is also something to be said for simplicity. If you go read Stuart’s article, you’ll notice how many CSS3 rules it takes to emulate “a.local”.

That’s a little unfair. It actually takes two rules: one to style all links with http, and one to style absolute links that are to this domain (which could be local links). If you don’t use absolute links inside a domain, then it’s only one rule. The reason that my code listed six rules were that I do sometimes use absolute links in the domain, I also wanted a different effect on link hover, and I wanted to style one particular external link differently (which most people would not want to do). Moreover, a fair few of those rules could be combined together by putting multiple selectors in and separating them with commas. Personally, I think that explicitly tagging local links as “local” is bad, because it leaves open the possibility that a local link might not be classed, or that an external link might be erroneously classed. Browsers don’t support the CSS3 selectors yet, but that’s not the fault of the technique.

I'm currently available for hire, to help you plan, architect, and build new systems, and for technical writing and articles. You can take a look at some projects I've worked on and some of my writing. If you'd like to talk about your upcoming project, do get in touch.

More in the discussion (powered by webmentions)

  • (no mentions, yet.)