Re: is <div style="display: inline"> identical to <span>?
On Mar 18, 1:19 am, Ben C <spams...@spam.eggs> wrote:
> They can look different in theory.
>
> In HTML 4, span can only contain members of the %inline group. So
>
> <span><div>hello</div></span>
>
> is invalid. The browser can do what it wants with it. For example it
> might close the span before the div and reopen it after it. This would
> mean that if you'd set span { color: red } for example, "hello" wouldn't
> get it.
>
> Having said that I haven't met a browser that doesn't just allow div
> nested inside span as if there were nothing wrong with it.
>
> <div style="display: inline"><div>hello</div></div>
>
> is valid and should always do what you expect.
I am only guessing... since inline element cannot contain any block
element, it doesn't matter whether it is
<span><div>hello</div></span>
or
<div style="display: inline"><div>hello</div></div>
Both of them are considered invalid the same way. (since they are
inline element containing a block element)
|