gpt4 book ai didi

xhtml - XHTML 中的空白处理

转载 作者:行者123 更新时间:2023-12-01 01:34:29 26 4
gpt4 key购买 nike

有没有关于如何正确处理 XHTML (1.0 Transitional) 中的空格的信息?似乎 XHTML 不使用标准的 XML 空白处理。

编辑:梅比我对我到底在寻找什么有点不准确。我对元素如何呈现比 XML 处理器如何处理更感兴趣。
例如,以下将呈现中间有 1 个空白:

<em> em content </em> following text

如果空间实际上有自己的格式,情况会变得更加复杂,例如 <a href="http://www.google.de"> content of the hyperlink </a> content after the hyperlink在超链接的末尾会有一个带下划线的空格,而 <a href="http://www.google.de"> content of the hyperlink</a> content after the hyperlink<br />不会在空格下划线。

似乎空格总是附加到先前的格式化范围,并且空格是在(内联)元素开始和结束标记上处理的。但这完全基于测试,我想知道是否有某种规范说明这种行为的表现如何。

最佳答案

来自 W3C Recommendation :

4.7. White Space handling in attribute values

When user agents process attributes, they do so according to Section 3.3.3 of [XML]:

  • Strip leading and trailing white space.
  • Map sequences of one or more white space characters (including line breaks) to a single inter-word space.


对于标签之间的空白,请参阅 section 3.2标准 9:

3.2. User Agent Conformance

[1-8 snipped]

9. White space is handled according to the following rules. The following characters are defined in [XML] white space characters:

  • SPACE (&#x0020;)
  • HORIZONTAL TABULATION (&#x0009;)
  • CARRIAGE RETURN (&#x000D;)
  • LINE FEED (&#x000A;)

The XML processor normalizes different systems' line end codes into one single LINE FEED character, that is passed up to the application.

The user agent must use the definition from CSS for processing whitespace characters [CSS2]. Note that the CSS2 recommendation does not explicitly address the issue of whitespace handling in non-Latin character sets. This will be addressed in a future version of CSS, at which time this reference will be updated.



另见 C.15 部分:

C.15. White Space Characters in HTML vs. XML

Some characters that are legal in HTML documents, are illegal in XML document. For example, in HTML, the Formfeed character (U+000C) is treated as white space, in XHTML, due to XML's definition of characters, it is illegal.

关于xhtml - XHTML 中的空白处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2836424/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com