Skip to content

24 ways to impress your friends

Vote down?

Daniel Skinner

Another selector I used is to check whether external links have a rel attribute.

This will only work if relative internal links are used.

/* Highlight external links with no rel attribute */
a[href^=“http://”]:not([rel]), a[href^=“http://”][rel=”“] {



This selector highlights all links whose href attribute starts with http:// only if the link doesn’t have a rel attribute (or it is empty).

The reason I do this is because you cannot use the target attribute in XHTML. I give all external links rel=“external” and a piece of JavaScript finds these links and adds a target attribute to it (which is perfectly valid DOM).

You could easily modify the selector to find all external links that do not have a target attribute.