问题描述
我知道在 XML 和 HTML 的文本节点中如何处理空白,但我不确定标签元素本身内部的空白.显然,标签内使用空格来分隔属性,但是在'<'之后有空格是否有效还是在'>'之前?
I know how white space is handled in text nodes for XML and HTML, but I'm uncertain about white spaces inside tag elements themselves. Obviously, white spaces are used inside tags to separate attributes, but is it valid to have white spaces after '<' or before '>'?
例如:
< foo >
< /foo >
甚至:
<foo>
< / foo >
这些标签是有效的 XML 吗?假设它们是实际的 HTML 标记名称,那么 HTML 呢?
Are these tags valid XML? What about HTML, assuming they were actual HTML tag names?
推荐答案
规范(第 3.1 节开始标签、结束标签和空元素标签) 说 '<' 和标签名称之间没有空格,在 '</' 和标签名称,或在 '/>' 内.不过,您可以在标签名称后添加空格:
The specification (section 3.1 Start-tags, end-tags, and empty-element tags) says that there is no white space between the '<' and the tag name, between '</' and the tag name, or inside '/>'. You can add white space after the tag name, though:
<foo >
</foo >
<bar
/>
这篇关于XML/HTML 标记内的空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!




大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)