0

this question involves doctype so I won't be using JFiddle because there the doctype is automatically included

you can copy and paste into a file.html and run it though

I'm using to display some information and I when I use it without using a doctype declaration it works fine (no vertical spacing between the span elements)

<html>

<style>

   span {
      font-family:sans-serif;
      font-size:9px;
      color:#666666;
   }
   #statusPass {
      color:#66CC00;
   }
   #statusFail {
      color:#FF0000;
   }

</style>

<body>

<span>process... </span>
<span id="statusPass">pass<br /></span>
<span>process... </span>
<span id="statusFail">fail<br /></span>

</body>
</html>

However if I add a doctype tag it seems to automatically add vertical spacing between the spans, I'm not sure why but it there a way to remove it?

<!DOCTYPE html> <!-- this guy's the culprit -->
<html>

<style>

   span {
      font-family:sans-serif;
      font-size:9px;
      color:#666666;
   }
   #statusPass {
      color:#66CC00;
   }
   #statusFail {
      color:#FF0000;
   }

</style>

<body>

<span>process... </span>
<span id="statusPass">pass<br /></span>
<span>process... </span>
<span id="statusFail">fail<br /></span>

</body>
</html>
TheLovelySausage
  • 3,838
  • 15
  • 56
  • 106

2 Answers2

1

It seems to work when I use p instead of span and add extra css

<!DOCTYPE html>
<html>

<style>

   p {
       margin:0; padding:0;
       font-family:sans-serif;
       font-size:9px;
       color:#666666;
   }
   #statusPass {
       color:#66CC00;
   }
   #statusFail {
       color:#FF0000;
   }

</style>

<body>

<p>process...
<span id="statusPass">pass</span>
</p>

<p>process...
<span id="statusFail">fail</span>
</p>

</body>
</html>
TheLovelySausage
  • 3,838
  • 15
  • 56
  • 106
0

Remove the white space (new line) between the span elements.

Bugs in older browsers (emulated in newer browsers when the Doctype is missing) failed to render some space between elements that should have been rendered.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • That doesn't work. Even if you interpret the question to mean horizontal spacing, before the question was clarified, quirks mode vs standards mode wouldn't change it. As vertical spacing, removing the spaces doesn't work because the strut in the line box creates the additional vertical space, regardless of the presence of the white space between the span elements. – Alohci Dec 01 '15 at 17:16