Tom Ritter
Tom Ritter

Reputation: 101310

What are the valid HTML tags in RSS Feeds?

I've looked around, and it doesn't seem like there's any standard of what HTML tags are 'allowed' in RSS - you could put anything in. But the readers I tested only allow certain things.

In my initial testing, it seems like simple styling tags like <b> are fine. So is inline styles like <span style="color:red"> <img>'s seems to work. But <iframe>'s are ignored, as are <script> blocks. Onclick attributes don't work. <style> blocks work in some readers but not others

Is there a general consensus, standard, or compatability site listing what is and isn't supported in what readers? I want to know what the subset of HTMl tags I can use in feeds is.

Upvotes: 11

Views: 10785

Answers (5)

ashraf mohammed
ashraf mohammed

Reputation: 1350

 <title>How to parse full html content in xml feeds</title>
 <description><![CDATA[<html><body>Any code html is valid here like &npsb; 
 and what ever you want to transfer</body></html>]]></description>
 <guid>http://example.com/your-news-id</guid>

Upvotes: 11

comodoro
comodoro

Reputation: 1566

In fact, no HTML attributes are allowed in RSS feeds. Only XML tags listed in the specification posted above are allowed. Also, since it is XML, only some Unicode encodings are allowed (e.g. UTF-8). That many RSS providers do not respect the standard is another matter.

Upvotes: -1

Stijn Sanders
Stijn Sanders

Reputation: 36840

I think the 'right' thing to do is either include an xhtml namespace (xmlns:html="http://www.w3.org/1999/xhtml") or put the HTML data in a CDATA section.

Upvotes: 1

Eli
Eli

Reputation: 5610

I don't think there's any "official" answer. It might depend on what level of compatibility you're aiming for.

I'd keep it to the basic text formatting tags (STRONG, EM, etc) and IMG and A and that's about it.

Upvotes: 0

Matchu
Matchu

Reputation: 85784

I don't think there's a standard here - it's all about what the RSS reader itself is willing to implement. So my guess would be that, for example, Google Reader would wash out tags and the like and dangerous HTML and CSS attributes, and then allow whatever other sort of non-blacklisted tag you would dare to include.

So, yeah. There's no specification, and therefore likely no standard - just the same general XSS prevention techniques we see across the whole interwebs. Your only option is to try out various tags that you think may be contentious (though really I'd expect almost anything but CSS styling would be permitted) in different RSS readers to see what happens, or simply to have your content ready to fall back to a more basic format if the desired HTML/CSS is not permitted.

What in particular are you trying to do? You may be able to get better answers if you can specify - or is this just a question of curiosity?

Upvotes: 2

Related Questions