53

Can I have multiple values for rel attributes? Like so:

<a href="#" rel="value1 nofollow">Link</a>

.. is it valid and cross-browser compatible?

Peter
  • 127,331
  • 53
  • 180
  • 211
eozzy
  • 66,048
  • 104
  • 272
  • 428

6 Answers6

71

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 list of link types.

Seth Battin
  • 2,811
  • 22
  • 36
Zach Hirsch
  • 24,631
  • 8
  • 32
  • 29
  • 3
    +1, but I wouldn't make assumptions in web design - especially regarding browser support... – Moshe Dec 10 '09 at 04:42
  • 6
    Well, in this case the important thing is to have crawler support ;-) – Marc Climent Feb 27 '14 at 14:57
  • 2
    Valid. How else would you be able to tell a search engine that some link is "nofollow" and _at the same time_ signal a browser "noopener" for JS security reasons... – isync Sep 24 '20 at 13:59
6

Yes it's valid and it works on all browsers, including IE7 and IE8

5

Definitely valid.

You can also do the same thing with the class attribute. This is handy for CSS styling.

HTML:

<span class="foo bar more classes">Stuff</span>
<span class="bar">More bar</span>

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.

Moshe
  • 57,511
  • 78
  • 272
  • 425
  • 4
    You can't actually add multiple values to the id attribute, nor can you put spaces in the id value. The id of a HTML Element is a 1 to 1 relationship, therefore each value can only occur once per page. – Mark Rabjohn Aug 14 '14 at 08:27
  • Thanks. Fixed my answer. – Moshe Mar 16 '16 at 16:25
3

yes you can and it's valid: e.g: 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..

http://www.w3schools.com/tags/att_a_rel.asp

WPDevotion
  • 378
  • 3
  • 16
0

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.

I thought I would post my answer, as I came across this thread after doing a Google search for the same question.

mattauckland
  • 483
  • 1
  • 7
  • 17
0

I tried this with jQuery Mobile and it doesn't work. It works if I remove the second attribute.

rel="external nofollow"
Lee
  • 13
  • 1
  • 3