OK, I accept

This site uses cookies. By using this site, you acknowledge and accept this.

Your basket is empty
Login not logged in

Full Knowledgebase Listing

Why does HTML get stripped from product and category descriptions?

[#63] Last update 13 Mar 2017

Kartris allows you to add HTML to product and category descriptions. However, when these descriptions are shown in product and category listings, or search results, the HTML tags are stripped out. Therefore, text marked up as BOLD or otherwise styled will appear, but without any additional styling.

This behaviour is intended. The problem is fundamentally down to truncation; when we display products and categories on their own pages, we show the entire description. We can therefore assume that any HTML tags that are opened, will be closed again.

But when we show them on listings pages, we truncate the descriptions down to a few hundred characters (because descriptions can be very long otherwise). With text that contains HTML, it would therefore be possible for the truncation to result in text that has opening HTML tags (for bold, or italic, for example) but no corresponding closing tags. Or in some cases, opening DIV tags, with no closing ones. In both cases, this will result in a page which is malformed; either because bold text continues for the rest of the page, or because the opening DIV without a closing one breaks the actual layout. Worse, it's also possible that an opening HTML tag gets broken halfway through, in which case much of the page might disappear (as the browser sees a tag opened, and assumes everything after that is part of the tag).

To avoid these issues, where descriptions are truncated, we always strip out the HTML tags first, so there is no risk of things getting broken by stray tags.

Powered by kartris