Welcome to WebmasterWorld Guest from 54.159.19.75

Forum Moderators: not2easy

Message Too Old, No Replies

Can I use CSS to add rel="nofollow"?

     
1:46 am on Mar 18, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 28, 2009
posts: 68
votes: 0


More precisely: I have an RSS news feed on my site. I can control its appearance with CSS. Can I use CSS to automatically add the rel="nofollow" attribute to all links in that feed?
2:47 am on Mar 18, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


No. CSS is all about styling.
2:54 am on Mar 18, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 28, 2009
posts: 68
votes: 0


Hmmm maybe php, then? If my current rss php is
<?php readfile('http://my_feed')?>

Is there any code I can add to this, so that <a> tags are added the rel="nofollow" attribute? Something along these lines:
$('#a').attr( 'rel', 'nofollow' );
5:11 am on Apr 19, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 14, 2004
posts:864
votes: 0


You could do it with preg_replace/match using regex. I don't think you would want to be using jQuery to be telling search engines that you distrust a link.
6:22 am on Apr 19, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 28, 2009
posts: 68
votes: 0


Actually I have got help from the excellent guys of Rssinclude in the meantime, and I now have a script that adds nofollow to all news links.

It's only natural to distrust news sites; isn't it? :-)
4:37 pm on Apr 19, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


What if the Javascript (jQuery) doesn't execute? Many S.E.'s don't parse Javascript. So if it "looks like it works" it's only because you have JS enabled.

The only solid solution is the one suggested above - grab the feed content, use preg_replace to add nofollow to the link, then output the modified content.