Let’s say an empty div or span that will be used by JavaScript to add something, as
<div id='id'></div>
Semantically it’s wrong, because it can’t be empty (I forgot in the moment the reason). We use then
<div id='id'> </div>
until, if, JavaScript do its magic.
But I also don’t like it, because there’s not really a space there. I’d do
<div id='id' />
but self closing tags explains its issues.
Is there any other solution I can’t think of? or is & nbsp; really the best?
Note that this is about HTML document, not how it’s rendered by a browser. For browser we just set it to not be rendered and then show it with JS.
Edit: Yes, the div is semantcally wrong. It’s meant to have some content in it, otherwise it’s useless semantically. Eric Meyer CSS Diagnostic says it. If I’m understanding it wrong, instead of negging me, teach me…
if the schema allows it
second:
because in both cases childNodes length is 0
you need
because of what?