P Tags and Flash
By Adrian Sutton
One of the most difficult situations to work with is when your output needs to be rendered using Flash. The HTML support in Flash is absolutely horrendous – worse even than in most email clients. Contrary to popular belief, Flash does support P tags. You will however need to ensure the text field is set to multiline. The BR tag is also only supported in multiline fields. The problem most people hit is that Flash doesn’t support the margin-top and margin-bottom attributes so you can’t get rid of the blank line between paragraphs.
The list of HTML tags supported by flash is very short, so you will need to disable most of the editor functionality, however since flash does support things like bullet lists, for the most intuitive editing experience, it’s best to use P tags to break up the paragraphs rather than BRs.
Instead of avoiding P tags to avoid the extra white space, use a two part approach. In the editor, use P tags for paragraphs, and include the CSS:
p { margin-top: 0; margin-bottom: 0; }
Then before passing the HTML into Flash, filter it to replace
with 1{#footlink1:1283791519502.footnote}. Store the original content, with the P tags, in the database so that they are still present when the user goes back to edit existing content. You will need to disable any formatting that applies to the paragraph element – most notably alignment. There is no way to support alignment without a block tag and P is the only available block tag within Flash. If you need alignment support, you will have to use P tags and put up with the extra white space. Lists will still work correctly2{#footlink2:1283791760407.footnote} because the editor is working with the P tags, and the Flash renderer
In any case for Flash you will need to disable a lot of functionality to ensure only the supported elements are inserted. Essentially, bold, italic, underline, font face, font size and font color, images and hyperlinks. There are a few other CSS properties supported, but still very limited.
The limitations in Flash do provide significant challenges to providing a powerful and intuitive HTML editor, but the user experience will almost always be better if the editor works with P tags, and then they are replaced before rendering, using CSS within the editor to ensure consistent rendering. In all cases, it is vitally important to heavily restrict the functionality that is available in the editor. If at all possible, avoiding the need to render HTML within Flash is usually the best option, but not always feasible.
1 – Flash 9 doesn’t support the DIV tag, otherwise that would be the ideal alternative. ↩
2 – tables are not supported by Flash anyway↩