When reading online, I’m a little reluctant to click if there are links to other sites. If the post is short, I read the post and open it separately, or if the post is long, I open it with a new tab in the middle. In this case, how about marking the external link nicely? There is a really simple way to display external links with just one line of CSS.
If you look at the link below, there is no link emoji on my blog link.
However, on external links, you will see an emoji following the link.
The secret is just one line of CSS below.
You can copy the code above and modify it appropriately.
- Replace the
.articlewith the parent element surrounding the article
address.comwith the site address to apply
- If you are going to apply the style on the back like me, keep
:afteralive (if you are going to decorate the front, change it to
- Then, apply the CSS style you want.
You will understand the CSS one by one.
.article– an element contained in other element with ‘article’ class
a– Among the ‘a’ tags
a[href*="//"]– Matches the ‘href’ attribute containing the character ‘//’.
:not([href*="address.com"])– And with a selector named ‘:not’, only links that do not contain address.com in the ‘href’ attribute are selected.
In the end, only external links will affected. 🙂