White space inside XML/HTML tags(XML/HTML 标记内的空白)
问题描述
我知道在 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 标记内的空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:XML/HTML 标记内的空白
				
        
 
            
        基础教程推荐
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
 - 如何使用 CSS 显示和隐藏 div? 2022-01-01
 - 每次设置弹出窗口的焦点 2022-01-01
 - Node.js 有没有好的索引/搜索引擎? 2022-01-01
 - WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
 - 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
 - 什么是不使用 jQuery 的经验技术原因? 2022-01-01
 - jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
 - 如何在特定日期之前获取消息? 2022-01-01
 - Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				