simple div containing span won't size correctly
        Posted  
        
            by brad
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by brad
        
        
        
        Published on 2010-04-10T16:37:14Z
        Indexed on 
            2010/04/10
            16:43 UTC
        
        
        Read the original article
        Hit count: 374
        
I thought I was pretty knowledgeable about CSS but this simple problem baffles me.
<div><span>sample text</span></div>
results in the div's height being smaller than the height of the span if the span has padding.
I realize that there are ways to use "float" to make the div size correctly, but floats always seem to introduce undesired side effects.
Isn't there a clean simple way to tell the div to size to fit its contents? Seems pretty basic to me. Maybe I'm missing something.
© Stack Overflow or respective owner