为什么单个 textarea 会弄乱 xhtml 后面的所有内容?

发布于 2024-08-05 06:10:27 字数 286 浏览 7 评论 0原文

我的网络程序遇到问题。我的表单中有一个文本区域,有时文本区域中没有任何内容,所以genshi模板引擎只是将其输出为,

<textarea xxxx />

问题来了,所有以下标签都在文本区域中。为什么所有浏览器都不能正确处理单个文本区域?

如果我把它写成

<textarea xxxx></textarea>

一切正常。为什么单个文本区域会混淆 xhtml 中的以下标签?

I encounter a problem in my web program. I got a textarea in my form, sometimes there is nothing in textarea, so genshi template engine just output it as

<textarea xxxx />

and here comes the problem, all following tags are in the textarea. Why all browser can't handle single textarea correctly?

If I write it as

<textarea xxxx></textarea>

and everything works fine. Why a single textarea messes following tags in xhtml?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉默的熊 2024-08-12 06:10:27

因为您可能正在使用 text/html 内容类型来提供 XHTML 并使其被作为 HTML 进行处理。 XML 样式的自闭合标记在 HTML 中不存在(因此您必须使用明确的开始和结束标记,除非它们被禁止(例如 img 上的结束标记)或可选(例如 body 元素上的开始和结束标记)。

如果 然后用作 application/xhtml+xml(并告别 Internet Explorer 的支持)

(这就是为什么我在大多数项目中坚持使用 HTML 4.01)

您希望将页面处理为 XHTML , 。 /www.w3.org/TR/xhtml-media-types/" rel="nofollow noreferrer">http://www.w3.org/TR/xhtml-media-types/ 了解更多详细信息(包括全套兼容性指南,将您的 XHTML 调整为 HTML 用户代理可以处理的形状)。

Because you are, presumably, serving your XHTML with a text/html Content-type and causing it to be processed as HTML. XML style self-closing tags do not exist in HTML (so you have to use explicit start and end tags, except where they are forbidden (e.g. end tags on img) or optional (e.g. start and end tags on the body element).

If you want to have your pages processed as XHTML then serve as application/xhtml+xml (and kiss goodbye to support from Internet Explorer).

(This is why I stick to HTML 4.01 for most projects)

See http://www.w3.org/TR/xhtml-media-types/ for more details (including the full set of compatibility guidelines to munge your XHTML into a shape where HTML user agents can cope with it).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文