How to unify the space width in different browsers

521 Views Asked by At

The space   shows different width in Chrome and IE, how to unify them?

In IE it is shorter than in Chrome and Firefox.

I've tried use the font but nothing seems to have happened.

<span style="font-family: 宋体, SimSun; font-size: 20px;">&nbsp;&nbsp;</span>
2

There are 2 best solutions below

1
On BEST ANSWER

You can try to add padding in css to add a similar amount of space in span across various browsers.

Try to refer example below.

<!doctype html>
<head>
  <title>demo</title>
<style>
 span.padd{padding-left:60px;}
</style>
</head>
<body>

<span class="padd">Demo Text</span>

</body>
</html>

0
On

Do not use &nbsp; as a separator between two elements, for exactly this reason.

Instead, you're better off setting the CSS width: attribute on the <span> to the exact width you need:

<span style="width: 10px"></span>

Note: I only show px here so the syntax is correct. You should pick a better unit of measure. See this.

Frankly, even that's not a great solution. It would probably be better to put margin on the things that you need to separate, than to put a separator between them.