When the div tag is used, it creates a new line before and after itself.
This
display: none
makes the div invisible and does not occupy any space.
However, I am confused by something when I look at the source code:
<p>There is<div style="display:none"></div> a paragraph</p>
I expected the result to be:
There is a paragraph
But in reality, it appears as:
There is
a paragraph
Why did this happen?
And when using float, I encounter a similar issue, for example:
<p>this is a paragraph <div style="float:left; background:blue;">something..</div> within a div</p>
The expected output was:
something... this is a paragraph within a div
But in reality, it displays as:
this is a paragraph
something... within a div