CSS: Styling a link based on its href

2020-05-09 19:16发布

I have a 3rd party link on my website which I want to style. but it don't have any class or id which I can target. Only thing it have is its unique href value. Is it possible to style a anchor tag based on its href value.

2条回答
霸刀☆藐视天下
2楼-- · 2020-05-09 19:18

You can use css attribute selector like:

a[href="http://google.com"]{
   your css code here ...
}

More information here.

Thanks.

查看更多
\"骚年 ilove
3楼-- · 2020-05-09 19:29

You can use href css selector to style a tag based on link:

a[href="your url here"]{
    background:red;
}

Demo

查看更多
登录 后发表回答