Search code examples
rss

Maximum length of RSS description item


Is there a length limit or maximum size for description tag inside an RSS item?

Also, does this tag accommodate HTML tags?

I will be generating both the <description> and <content:encoded> from the same source HTML and also wanted to know if the <description> tag accommodates HTML.


Solution

  • As I know there are not a length limit. 2

    In RSS 0.91, various elements are restricted to 500 or 100 characters. There can be no more than 15 < item >s in a 0.91 < channel >. There are no string-length or XML-level limits in RSS 0.92 and greater. Processors may impose their own limits, and generators may have preferences that say no more than a certain number of < item >s can appear in a channel, or that strings are limited in length.

    Rss 2.0

    For all elements defined in the RSS specification that enclose character data, the text should be interpreted as plain text with the exception of an item's description element, which must be suitable for presentation as HTML. All of these elements must not contain child elements.

    There's no limit on the length of character data that can be contained in an RSS element.

    So do you want to cut text somewhere and add ...? In this case just use substr.

    $description = substr($description, 0, 250)."...";
    

    Replace 250 by the size you want.