& nbsp without semicolon
I am using prototype.js in a web application. I populate some Divs dynamically by selecting some radio buttons. Before filling the content in the Div, I clear the previous content using the prototype update method as -
$('item').update('');
In IE this breaks the line automatically, but not in Firefox 3.5. So, to work the same way as IE, I changed the code as -
$('item').update(' ');
This has now worked for me as expected. But generally "& nbsp" is used with a semicolon ($ nbsp;) . I want to know if this code might fail. For example, are there any chances where & nbsp will appear instead of a space? But some browsers may be smart enough to detect a coding error by a programmer and auto-correct it.
The trailing semicolon can be omitted, but is not recommended at all. See this note in the HTML 4 spec regarding symbolic links :
In SGML, the final ";" after a symbolic link in some cases (for example, on a line break or immediately before a tag). In other circumstances, it cannot be eliminated (for example, in the middle of a word). We strongly recommend using ";" in all cases, to avoid problems with user agents that require this symbol to be present.
source to share