CSS - 根据其“rel"设置链接样式属性? [英] CSS - style a link based on its "rel" attribute?

查看:24
本文介绍了CSS - 根据其“rel"设置链接样式属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<a href="http://google.com" rel="external"> LINK </a>

是否可以为 rel="external" 添加 css 规则?

is it possible to add css rules for rel="external" ?

推荐答案

Felix Kling 和三十多点建议使用 [att=val] 属性选择器(a[rel="external"]).但是这仅在 externalonly rel 值时才有效.

Felix Kling and thirtydot suggested to use the [att=val] attribute selector (a[rel="external"]). But this will only work if external is the only rel value.

如果您想设置可能有 1 个或多个 rel 值的链接的样式,您应该使用 [att~=val] 属性选择器:

If you want to style links that could have 1 or more rel values, you should use the [att~=val] attribute selector:

a[rel~="external"](注意 波浪号 字符)

此类链接的示例可能是:

An example for such a link could be:

<a href="http://google.com" rel="external nofollow">LINK</a>

<小时>

参见 http://www.w3.org/TR/css3-selectors/#attribute-表示规范.

这篇关于CSS - 根据其“rel"设置链接样式属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆