我正在努力更好地了解
HTML空白处理模型.现在我正在比较两个HTML片段:
z
和
z
第一个代码片段被重绘时,会产生两行:“a”和“z”(所以第一行有一个尾随空格).
第二个片段产生两行:“a”和“z”.第二行没有领先空间.
If a space (U+0020) at the beginning of a line has ‘white-space’ set to ‘normal’, ‘nowrap’, or ‘pre-line’, it is removed.
All tabs (U+0009) are rendered as a horizontal shift that lines up the start edge of the next glyph with the next tab stop. Tab stops occur at points that are multiples of 8 times the width of a space (U+0020) rendered in the block’s font from the block’s starting content edge.
If a space (U+0020) at the end of a line has ‘white-space’ set to ‘normal’, ‘nowrap’, or ‘pre-line’, it is also removed.
If spaces (U+0020) or tabs (U+0009) at the end of a line have ‘white-space’ set to ‘pre-wrap’, UAs may visually collapse them.
对此的幼稚阅读将表明,由于要删除行的开头或结尾的空格(当“空白”为“正常”)时,我的第一个片段应该不会导致尾随空格.但事实并非如此.
发生什么了?
我目前的理论是< br>被秘密地算作一个“字符”,在第一个代码片段中,它阻止了尾随空格处于其行的“结束”.但我真的不知道.
编辑:要清楚,我知道如何使用& nbsp;随意创建空格.我的问题是关于什么规则(关于某些规范)会引起上述行为.