CSS: Style external links

前端 未结 8 1798
甜味超标
甜味超标 2021-01-30 16:55

I want to style all external links in my website (Wordpress). I\'m trying with:

.post p a[href^=\"http://\"]:after

But Wordpress put the entire

8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-30 17:55

    Using some special CSS syntax you can easily do this. Here is one way that should work for both the HTTP and HTTPS protocols:

    a[href^="http://"]:not([href*="example.com"]):after,
    a[href^="https://"]:not([href*="example.com"]):after{
        content: " (EXTERNAL)" 
    }
    

    You can view an example styling of external links.

提交回复
热议问题