long time;

<span> with "float: right" inside "white-space: pre"

The following HTML:

<div style="white-space: pre">
  long time; <span style="float: right;">// know C?</span>
</div>
Run code

differs in WebKit and Gecko in different ways. With WebKit, the contents of the range remain on the same line as the previous text, but with Gecko they move to a new line.

Which behavior is right and why?

+4
source share
1 answer

I will have another attempt to answer this question ...

The preliminary directive white-spaceinterprets the space literally. Line breaks, spaces and tabs are displayed by the browser (br shortcuts are also considered line breaks). So

<div>   hello

world</div>

... displayed as

    hello

world

float: right , , .

Firefox , div . Chrome ( divs , , ). . .

http://jsfiddle.net/k5aueocr/

white-space: pre ( , , ), , , , . , CSS, .

+1

All Articles