Afficher un message
Vieux 18/03/2008, 09h19   #6
Ben C
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is <div style="display: inline"> identical to <span>?

On 2008-03-18, Summercool <Summercoolness@gmail.com> wrote:
> On Mar 17, 5:01 pm, Michael Fesser <neti...@gmx.de> wrote:
>
>> No. The rendered result might look the same, but the elements are still
>> completely different and have to follow the rules of the DTD.

>
> How about looking it this way: is there a case where a
>
> <div style="display: inline">
>
> would render differently than a <span>, or are they always the same?
>
> The same goes for <span style="display: block"> -- is there a case it
> can render differently than a <div>, or it is always the same?


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.
  Réponse avec citation
 
Page generated in 0,04819 seconds with 9 queries