To find the length in text characters, you can simply use the textContent.length property for strings.
Code:
<!DOCTYPE html>
<html>
<span id="test1">Hello World!</span>
<p id="test2">
<!-- The width of span tag above goes here with document.getElementById("").innerText -->
</p>
<script>
var spanLength = document.getElementById("test1").textContent.length;
document.getElementById("test2").innerText = spanLength;
</script>
</html>
Also the innerHTML property isn't for changing text in an element, it is for adding new html elements inside that element. Use innerText instead.
Now, if you want the width of an html element in px, you can use the offsetWidth property.
Code:
<!DOCTYPE html>
<html>
<span id="test1">Hello World!</span>
<p id="test2">
<!-- The width of span tag above goes here with document.getElementById("").innerText -->
</p>
<script>
var spanLength = document.getElementById("test1").offsetWidth;
document.getElementById("test2").innerText = spanLength + "px";
</script>
</html>