Why are the following 2 times of day not displayed the same and what can I do to make the second time look like the first?
开发者_高级运维<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<div>
8:00
<span>8</span>
<span>:</span>
<span >00</span>
</div>
</body>
</html>
Get rid of the newlines between span tags. Like this:
<div>
8:00
<span>8</span><span>:</span><span >00</span>
</div>
I'm hard pressed to find it in the spec, but it appears that virtually all browsers take all white spaces and "compress" it down to a single space.
Here's a related SO post.
The accepted answer there recommends using String.Format
to handle rendering more precisely -- this may help in your particular situation.
Update:
According the HTML 4 spec:
SGML (see [ISO8879], section 7.6.1) specifies that a line break immediately following a start tag must be ignored, as must a line break immediately before an end tag. This applies to all HTML elements without exception.
There's also an interesting write up describing this as a bug here.
精彩评论