开发者

Is there a way to style RSS/ATOM feeds?

开发者 https://www.devze.com 2023-04-08 19:33 出处:网络
One thing I\'ve noticed is that my blog posts show up very different in my RSS feed than on my actual blog. Presumably, this is because CSS doesn\'t apply to RSS feeds, so layout is messed up.

One thing I've noticed is that my blog posts show up very different in my RSS feed than on my actual blog. Presumably, this is because CSS doesn't apply to RSS feeds, so layout is messed up.

For example, if in my feed I have something like this:

<div class="right-floater">Some right-float text!</div>
<p>Normal paragraph text.</p>

...on the blog, it will display properly. In the actual RSS feed, it will be laid out sans CSS and the <div> will be to the left of the <p>, presumably.

Is there a way to add in a link to CSS stylesheet information to have reader applications load the styles so that things style properly when viewed in an appli开发者_运维百科cation like Google Reader?


It depends on the feed reader, but yes, most will ignore CSS entirely. Some (like Google Reader) will pay attention to the style attribute if it's "simple" enough, so you could write:

<div style="float: right">Some right-float text!</div>
<p>Normal paragraph text.</p>

For security reasons (primarily XSS avoidance), CSS has to pass through a filter. Only "known safe" CSS is allowed through.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号