✍ Evan Travers

Highlighting External Links Using CSS (opens in new tab)

I was talking with a coworker about a requirement to highlight links to external site on our product. While we were talking, I started wondering if you could achieve this just using a CSS change using pseudo-selectors... and after a few seconds in codepen I came up with this: If a link's href attribute doesn't begin with a / (basically isn't an relative link) then it assumes that the link is external and adds a cute link emoji. πŸ‘ a:not([href^="/"]):after { content: "πŸ”—"; } I'm not the first pe...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help