Html rel 属性的多个值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1878657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Multiple values for rel attribute
提问by eozzy
Can I have multiple values for rel attributes? Like so:
我可以为 rel 属性设置多个值吗?像这样:
<a href="#" rel="value1 nofollow">Link</a>
.. is it valid and cross-browser compatible?
..它是否有效且跨浏览器兼容?
回答by Zach Hirsch
It's valid.I'm not sure if it's supported by all browsers, though, but I would guess that it is.
这是有效的。不过,我不确定是否所有浏览器都支持它,但我猜它是。
rel = link-types [CI] This attribute describes the relationship from the current document to the anchor specified by the href attribute. The value of this attribute is a space-separated listof link types.
rel = link-types [CI] 该属性描述了从当前文档到由 href 属性指定的锚点的关系。此属性的值是以空格分隔的链接类型列表。
回答by Creation web Paris
Yes it's valid and it works on all browsers, including IE7 and IE8
是的,它有效并且适用于所有浏览器,包括 IE7 和 IE8
回答by Moshe
Definitely valid.
绝对有效。
You can also do the same thing with the class attribute. This is handy for CSS styling.
你也可以用 class 属性做同样的事情。这对于 CSS 样式很方便。
HTML:
HTML:
<span class="foo bar more classes">Stuff</span>
<span class="bar">More bar</span>
CSS
CSS
.foo{
color: #afafaf;
}
.bar{
border: 1px solid #0ff;
}
The first span would be gray and have the blue border, while the second span would just have the border.
第一个跨度将是灰色并具有蓝色边框,而第二个跨度将只有边框。
回答by mattauckland
Actually it isn't valid according to Structured Data Testing Tool.
实际上根据结构化数据测试工具它是无效的。
I tried this tonight, using the following
我今晚试过这个,使用以下
rel="publisher nofollow"
and it failed to validate the publisher. As soon as I removed the nofollow is validated ok again.
它未能验证发布者。一旦我删除了 nofollow 就再次验证正常。
I thought I would post my answer, as I came across this thread after doing a Google search for the same question.
我想我会发布我的答案,因为我在谷歌搜索相同的问题后遇到了这个线程。
回答by Lee
I tried this with jQuery Mobile and it doesn't work. It works if I remove the second attribute.
我用 jQuery Mobile 试过这个,但它不起作用。如果我删除第二个属性,它会起作用。
rel="external nofollow"
回答by Muhammad Nouman Khalid
yes you can and it's valid: e.g: rel='tag nofollow'
是的,你可以,它是有效的:例如: rel='tag nofollow'
<a expr:href='data:label.url' rel='tag nofollow'><data:label.name/></a>
just use values with giving "blank space" among them. The complete details of tags used inside rel are here..
只需使用值并在其中给出“空白”。rel 中使用的标签的完整细节在这里..