homepage Welcome to WebmasterWorld Guest from 50.17.79.35
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderator: open

CSS Forum

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




msg:4430460
 1:46 am on Mar 18, 2012 (gmt 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?

 

g1smd




msg:4430473
 2:47 am on Mar 18, 2012 (gmt 0)

No. CSS is all about styling.

SilverSpirit




msg:4430474
 2:54 am on Mar 18, 2012 (gmt 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' );

garyr_h




msg:4442799
 5:11 am on Apr 19, 2012 (gmt 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.

SilverSpirit




msg:4442812
 6:22 am on Apr 19, 2012 (gmt 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? :-)

rocknbil




msg:4443061
 4:37 pm on Apr 19, 2012 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved