HTML emsp实体的确切行为

时间:2017-02-26 01:54:49

标签: html entity word-wrap

我无法找到HTML emsp实体行为的确切参考。我已经查看了W3.org,MDN,W3schools和这里,但是我还没有找到描述它在HTML中没有应用任何特殊样式的破坏或包装行为的描述。

下面的代码显示了我所使用的实验,但我仍然对它何时会包装而感到困惑。有一个很好的参考?

<!DOCTYPE html>
<html>
<style>
body {
    font-size: 20px; font-family: Courier, fixed;
}
</style>
<body>

<p>Following is some text with some embedded emsp entities.<br>Here is one mid-word: sam&emsp;ple. <br>And here is one on each side of a dash: lock&emsp;-&emsp;step.<br>Then, how about one after a period?<br>Right after the next period is one and then a normal space.&emsp;  How about the standard space and then the emsp?<br>That sequence follows this sample sentence. &emsp;(Note that since the regular space came first, this can cause this text after it to become indented, whereas the emsp-then-regular space occurrence just before will never do that, I think.)  As long as I'm looking at them after the end of a sentence, we should try putting just one emsp after a sentence instead of the regular space caracter.<br>I thought that would stick the two sentences together, but it does not do so here.&emsp;Indeed, this is consistent with its behavior mid-word.  Okay, how about multiple occurrences of it?<br>There are 3 in the brackets here: [&emsp;&emsp;&emsp;] and so on.  I played with that last one a bit and I cannot get it to break after the 3 emsps.  Here, they seem to keep their width (they are not combined into one) and they are not breakable, not even either before the first or after the last one.  So, I seem to only be able to get the "[" and never the "]" as the first character on a new line.<br>Okay, more extremely, trying brackets around 5 emsp chars, a word, and 5 more emsp chars: [&emsp;&emsp;&emsp;&emsp;&emsp;word&emsp;&emsp;&emsp;&emsp;&emsp;] .<br>There we seem able to break before "word", but still never before "]".  What's going on there?
</p>
<p>From the examples above, I think the mystery around emsp characters is mostly resolved for me.</p>
<p>Consider the standard behavior for a regular space character.  Here, first remember that multiple occurrences of regular whitespace characters are all compressed as if they were a single regular space character.  Then, of course, the regular space character takes a certain width, and lines are never broken just before the regular space, only after it.  And the space normally allocated for a regular space character does not need to be rendered at the right edge of a box.</p>
<p>Similarly, text can break after an emsp character, but will not do so before.  It is wider than a regular space character, but mostly behaves like it.  Where it differs is if you have multiple emsp entities right next to each other.  In that case, no break will occur before, within, or after the group (unless there is whitespace before or after it, in which case the whitespace is the location of the break).  But if a set of multiple emsp characters are placed directly between two non-white characters (as in the bracket example above) then they are not compressed and no breaking occurs.  That's all I'm thinking of at the moment ...</p>

</body>
</html>

1 个答案:

答案 0 :(得分:1)

emsp是一个与字母宽度相同的空白区域&#34; M&#34;

我在http://opencoder.net/emsp.html

找到了简要说明

无论是破碎还是非破碎空间,我想说最简单的方法就是测试它。