如何将CSS样式表应用于RSS源

时间:2020-12-13 04:54:34

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?

在我的博客上,我使用了一些在我的样式表中定义的CSS类,但在RSS阅读器中,这些样式没有显示出来。我一直在寻找class =“whatever”并用style =“something:something;”代替。但这意味着每当我修改我的CSS时,我也需要修改我的RSS生成代码,并且它不适用于属于多个类的标记(即class =“snapshot accent”)。有没有办法从我的Feed中指向我的样式表?

5 个解决方案

#1


21  

The popular RSS readers WILL NOT bother downloading a style sheet, even if you provide one and link to it using <?xml-stylesheet?>.

流行的RSS阅读器不会打扰下载样式表,即使你提供样式表并使用<?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.

许多RSS阅读器只是从标签中删除所有内联样式属性。从今天的测试开始,我发现Outlook 2007似乎剥离了所有样式,例如,即使它们是内联的。

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.

好的RSS阅读器允许一组有限的内联样式属性。例如,请参阅Bloglines上的这篇文章,了解他们不会删除哪些CSS。从实验来看,谷歌阅读器似乎没有受到任何影响。

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的哲学确实是读者负责演示。许多人认为RSS应该是纯文本,而RSS源中的CSS是不合适的。在RSS源上添加不同的字体可能不合适。然而,某些类型的内容(例如,左侧浮动的图像,标题小心定位)需要最少量的样式以保持其语义含义。

#2


8  

The point of RSS is to be display agnostic. You should not be putting style attributes on your feed.

RSS的要点是显示不可知。您不应该在Feed上添加样式属性。

#3


3  

I found this blog post that describes how to add style to your RSS feed.

我发现这篇博文描述了如何为RSS源添加样式。

#4


1  

Because RSS is (supposed to be) XML, you can use XML stylesheets.

因为RSS(应该是)XML,所以您可以使用XML样式表。

http://www.w3.org/TR/xml-stylesheet/

http://www.w3.org/TR/xml-stylesheet/

#5


1  

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.

RSS源的目的是允许将内容轻松传输到站点之外的位置。整个想法是Feed中的内容没有格式,因此任何软件都可以读取。正在阅读您的Feed的程序负责如何以可视方式呈现它。例如,如果您有一个阅读RSS的网站,您可能希望将Feed解析为HTML,并以这种方式设置样式。但是,如果您正在构建一个桌面应用程序来读取源,那么您将以完全不同的方式实现格式。

#1


21  

The popular RSS readers WILL NOT bother downloading a style sheet, even if you provide one and link to it using <?xml-stylesheet?>.

流行的RSS阅读器不会打扰下载样式表,即使你提供样式表并使用<?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.

许多RSS阅读器只是从标签中删除所有内联样式属性。从今天的测试开始,我发现Outlook 2007似乎剥离了所有样式,例如,即使它们是内联的。

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.

好的RSS阅读器允许一组有限的内联样式属性。例如,请参阅Bloglines上的这篇文章,了解他们不会删除哪些CSS。从实验来看,谷歌阅读器似乎没有受到任何影响。

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的哲学确实是读者负责演示。许多人认为RSS应该是纯文本,而RSS源中的CSS是不合适的。在RSS源上添加不同的字体可能不合适。然而,某些类型的内容(例如,左侧浮动的图像,标题小心定位)需要最少量的样式以保持其语义含义。

#2


8  

The point of RSS is to be display agnostic. You should not be putting style attributes on your feed.

RSS的要点是显示不可知。您不应该在Feed上添加样式属性。

#3


3  

I found this blog post that describes how to add style to your RSS feed.

我发现这篇博文描述了如何为RSS源添加样式。

#4


1  

Because RSS is (supposed to be) XML, you can use XML stylesheets.

因为RSS(应该是)XML,所以您可以使用XML样式表。

http://www.w3.org/TR/xml-stylesheet/

http://www.w3.org/TR/xml-stylesheet/

#5


1  

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.

RSS源的目的是允许将内容轻松传输到站点之外的位置。整个想法是Feed中的内容没有格式,因此任何软件都可以读取。正在阅读您的Feed的程序负责如何以可视方式呈现它。例如,如果您有一个阅读RSS的网站,您可能希望将Feed解析为HTML,并以这种方式设置样式。但是,如果您正在构建一个桌面应用程序来读取源,那么您将以完全不同的方式实现格式。