![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
There is often a discussion of div style="display: inline" being able to make a block element into an inline element. so is it true that div style="display: inline" [any possible markup here...] /div is *identical* to span [any possible markup here...] span and vice versa, is <span style="display: block"> identical to a <div>? please, if you could, indicate whether this is your opinion, like from some years of experience, or whether there is a reference documenting that it is true? thanks so much. They're not identical, because they are different elements which mean |
#3
| |||
| |||
|
|
There is often a discussion of div style="display: inline" being able to make a block element into an inline element. |
|
so is it true that div style="display: inline" [any possible markup here...] /div is *identical* to span [any possible markup here...] span and vice versa, is <span style="display: block"> identical to a <div>? |
#4
| |||
| |||
|
|
No. The rendered result might look the same, but the elements are still completely different and have to follow the rules of the DTD. |
#5
| |||
| |||
|
|
.oO(Summercool) There is often a discussion of div style="display: inline" being able to make a block element into an inline element. This is _never_ possible. A block-level element remains a block-level element, regardless of the CSS rules you apply to it. |
|
CSS only affects the rendering, it doesn't change the element type. |
|
so is it true that div style="display: inline" [any possible markup here...] /div is *identical* to span [any possible markup here...] span and vice versa, is <span style="display: block"> identical to a <div>? No. The rendered result might look the same, but the elements are still completely different and have to follow the rules of the DTD. |
#6
| |||
| |||
|
|
On Mar 17, 5:01 pm, Michael Fesser <neti... (AT) gmx (DOT) 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? |
#7
| |||
| |||
|
|
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. |
#8
| |||
| |||
|
|
On Mar 18, 1:19 am, Ben C <spams... (AT) spam (DOT) 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) |
#9
| |||
| |||
|
|
I am only guessing... since inline element cannot contain any block element, it doesn't matter whether it is |
|
div style="display: inline"><div>hello</div></div |
![]() |
| Thread Tools | |
| Display Modes | |
| |