Theme & Front End CSS Beginner

Mark External Links With an Icon

Add a small arrow after links in your content that point to other websites, so readers know they're leaving.

Tested on WordPress 7.1 No plugin needed Updated
style.css 9 lines
/* Replace example.com with your own domain. */
.entry-content a[href^="http"]:not([href*="example.com"])::after,
.wp-block-post-content a[href^="http"]:not([href*="example.com"])::after {
	content: "\2197"; /* ↗ */
	display: inline-block;
	margin-left: 0.2em;
	font-size: 0.8em;
	text-decoration: none;
}

Where to add this

Recommended Additional CSS Appearance → Customize → Additional CSS, or your page builder's global CSS.
Child theme At the end of your child theme's style.css file.
A code snippets plugin As a CSS snippet set to load on the front end.

A small arrow on outgoing links sets expectations: readers know before they click that they’re going to another site. It’s a common pattern in documentation and long-form articles.

How it works

The selector matches links inside post content whose address starts with “http” and doesn’t contain your domain, so internal links and anchor links are left alone. ::after adds the north-east arrow after the link text. display: inline-block stops the link underline running under the arrow.

.entry-content is the usual content wrapper in classic themes and .wp-block-post-content in block themes.

Things to watch

  • Replace example.com with your domain, without “www”, so both versions match.
  • Links that wrap an image also get the arrow. Add :not(:has(img)) to the selector to skip them.

How to test it

Add an external link to a post. It should show a small ↗ after the text; internal links shouldn’t.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only