设计开放式文本输入 [英] Styling Open-Ended Text Inputs
问题描述
对待包含HTML标签的文本输入的最佳/推荐做法是什么?这个想法是正确显示输入,例如在不同的页面上。
正如所料,人们可以非常有创意地使用他们的HTML。例如:
< p> ...< / p>
< ul>< li> ...< / li>< / ul>
另一个例子:
< H1> ...< / H1>
一个更具挑战性的案例将是一个没有适当结构化HTML的输入。 < H1>你好< / P>< / H1>
。如果没有适当的照顾,这可能会打破整个页面布局。
我能想到的一件事是完全剥离标签。但是,可能有更好的方法。至少,我希望能够在段落之间放置适当的间距/边距;而不仅仅是将它们合并在一起。正如rlb.usa在评论中指出的那样,大多数人都依赖于一个成熟的,知名的,测试HTML渲染器以显示HTML。 WebKit,Qt和微软的Trident控件都是流行的选择,取决于平台。
如果你的渲染器有非标准代码问题,你可以运行它例如整理。
What's the best / recommended practice to treat a text input that contains HTML tags? The idea is to properly display the input e.g. on a different page.
As expected, people can be very creative with their HTML. For example:
<p>...</p>
<ul><li>...</li></ul>
Another example:
<h1>...</h1>
A more challenging case will be an input without a properly structured HTML e.g. <h1>Hello</p></h1>
. Without proper care, this has the potential to break the whole page layout.
One thing I could think of is to completely strip down the tags. However, there might be a much better way. To the very least, I'd like to be able to place a proper spacing / margin between the paragraphs; instead of just collapsing them together.
As rlb.usa noted in the comments, most people rely on a mature, well-tested HTML renderer to display HTML. WebKit, Qt, and Microsoft's Trident control are popular choices depending on the platform.
If you've got a renderer that has problems with nonstandard code, you could run it through something like tidy first.
这篇关于设计开放式文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!