A span can be a div, but a div can't be a span
I'm wondering if that (my title) is ever incorrect, other than for HTML validation. I've recently had to start supporting IE7 again (I've been lucky enough to not have to for the past 3 years or so) and the fact that div's can't be inline-block
has gotten me about 10 times in the past month due to the fact that I make everything a div
by default and then go back and stylize elements. So I'm considering making everything a span so that if I later go ba开发者_开发百科ck and make something inline-block I'm not trying to figure out why it's not working in IE7.
So my question -- Is there ever a case, in any browser (IE7+, FF, Webkit, Opera), that anyone knows of where a span can not act like a div? I'm not concerned about the HTML not validating due to having block elements inside inline ones.
I'm not going to directly answer your question, but I think this is worth saying.
I've recently had to start supporting IE7 again (I've been lucky enough to not have to for the past 3 years or so) and the fact that div's can't be inline-block has gotten me about 10 times in the past month
You can use display: inline-block
in IE7 for block-level elements such as div
s, with:
selector {
display: inline-block;
*display: inline;
zoom: 1
}
If you don't want to use an invalid but safe CSS hack (*property
), you can use conditional comments.
This may be of help: SPAN vs DIV (inline-block)
精彩评论