I just noticed a weird problem. Suppose you have this HTML:
case n° 1:
<span>123</span><span>456</span>
This is rendered all together:
123456
When you double-click this (I'm using Chrome), the entire 123456
gets selected. If you would add a space between them...
case n° 2:
<span>123</span> <span>456</span>
You get the texts separate
123 456
And double-clicking selects each of them individually. Now let's remove the space and introduce floats:
case n° 3:
<span style="float:right">123</span><span>456</span>
This time the texts get rendered separate like this:
456 123
However double-clicking either one still selects BOTH elements - I'm guessing because they are still technically next to each other in HTML. Let's put the space back in:
case n° 4:
<span style="float:right">123</span> <span>456</span>
The result still looks the same...
456 123
And - SURPRISE - double clicking either of them still selects both. What gives?
Interestingly, changing <span>
to <div>
fixes the problem. Playing around more, if at least one element has display: inline
or display: inline-block
then the strange behavior will be there, and only if both elements have display: block
will it work right. In addition, this also applies if instead of float
I use position: absolute
.
I would like to prevent this weird behavior. Why does it arise and how can I counter it?