HTML格式:文本未正确对齐

时间:2011-09-09 20:14:41

标签: html

<html><head></head>
<body>
<pre style="word-wrap:break-word;">
<HTML><head>  <style>.header {  color: black;   font-family: Arial, Helvetica, Sans-Serif;  font-size: 10pt }.footer {  color:black;    font-family: Arial, Helvetica, Sans-Serif;  font-size: 10pt;    font-style: italic; }  .body-header {   color: black;   font-family: Arial, Helvetica, Sans-Serif;  font-size: 10pt;    font-weight: bold; } .body-content {    color: black;   font-family: Arial, Helvetica, Sans-Serif;  font-size: 10pt;     }</style></head><body><p class="header">This is to notify you that you have an account balance that is greater than or below the threshold viewable on Online Banking for Business. The requested details appear below. <br></p>  <span class="body-header"> Account Number: </span><span class="body-content"> xxxxxxxxxxx </span><br><span class="body-header"> Balance Amount: </span><span class="body-content"> 110,xxx.95 </span><br><br><p class="footer">This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please report to gtmxxxxdesk@xxx.com or call 1-800-xxx-6xx4, and please delete this e-mail and destroy any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal.<br></p>  <p class="footer">Alert initiated: 08-Sep-2011 at 11:35AM Canada Eastern Time<br></p>  </body></HTML></pre>
</body>
</html>

当我将上述html放在一个文件中时,将其保存为.html,并在IE / FF中打开它,帐号:未向左前方对齐。这是为什么? 我知道有多个<html> , <head> and <body>标签,但是现在,这些是我需要使用的约束。即我无法摆脱它们:)

编辑:此外,在我的浏览器上,文本之间似乎有2个换行符: Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal以及后续行:Alert initiated

虽然只有<br>

3 个答案:

答案 0 :(得分:4)

那是因为你在文本之前有空格。在pre标记内,空格被解释为文字,不会被删除或折叠。

只要HTML代码尽可能地破碎,你就不能期望任何一致的结果。浏览器会尝试通过忽略某些标记来充分利用它,每个浏览器都会以不同的方式完成。

答案 1 :(得分:0)

更改此内容:

</p>  <span class="body-header"> Account Number:

到此:

</p><span class="body-header"> Account Number:

似乎为我工作...... jsFiddle

答案 2 :(得分:0)

啊哈!我找到了问题。

您需要删除</p><span>代码=)之间的空格。

像这样:

<br></p><span class="body-header"> Account Number: