On my blog I use some CSS classes which are defined in my stylesheet, but in RSS readers those styles don't show up. I had been searching for class="whatever"
and replacing with style="something: something;"
. But this means whenever I modify my CSS I need to modify my RSS-generating code too, and it doesn't work for a tag which belongs to multiple classes (i.e. class="snapshot accent"
). Is there any way to point to my stylesheet from my feed?
views:
1440answers:
7The point of RSS is to be display agnostic. You should not be putting style attributes on your feed.
I found this blog post that describes how to add style to your RSS feed.
Because RSS is (supposed to be) XML, you can use XML stylesheets.
The purpose of an RSS feed is to allow the easy transmission of content to places outside your site. The whole idea is that the content within the feed is format-free, so that it can be read by any piece of software. The program that is reading the your feed is in charge of how to present it visually. For example, if you had a website that read RSS, you would want to parse the feed into HTML, and style it that way. However, if you were building a desktop application to read the feed, you would implement the formatting quite differently.
The popular RSS readers WILL NOT bother downloading a style sheet, even if you provide one and link to it using <?xml-stylesheet?>
.
Many RSS readers simply strip all inline style
attributes from your tags. From testing today, I discovered that Outlook 2007 seems to strip out all styles, for example, even if they are inline.
Good RSS readers allow a limited set of inline style
attributes. See, for example, this article at Bloglines about what CSS they won't strip. From experimentation, Google Reader seems to pass through certain styles unharmed.
The philosophy of RSS is indeed that the reader is responsible for presentation. Many people think that RSS should be plain text and that CSS in RSS feeds is inappropriate. It's probably not appropriate to impose a different font on your RSS feeds. However, certain types of content (for example, images floated on the left, with captions positioned carefully) require a minimal amount of styling in order to maintain their semantic meaning.
RSS is XML. XML is pure data for machines. XML style sheet is shorthand for mere humans who are XML-illiterate, who are DTD-entities-illiterate, and also who can't manually subscribe to the given RSS feed him/herself.