Chris Ferdinandi 5/28/2026

How to add icons to external links with CSS

Read Original

This article explains how to automatically add icons after external links on a website using modern CSS techniques. It covers targeting links that start with 'http' while excluding internal links, button-styled links, and links already containing SVG icons. The tutorial demonstrates using the `::after` pseudo-element with CSS mask and background-color properties to display an external link icon that inherits the link's color. It addresses accessibility concerns by providing visual cues for external links instead of relying solely on `target="_blank"`.

How to add icons to external links with CSS

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet