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 back 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.
The phrasing elements can only contain other phrasing elements, for example, you can't put div inside span.
Span and div are both generic HTML elements that group together related parts of a web page. However, they serve different functions. A div element is used for block-level organization and styling of page elements, whereas a span element is used for inline organization and styling.
Yes. You can have a span within a span .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With