I'm looking for a CSS element that behaves like a table, where the size of the container will always be just big enough to surround the data inside, and will grow or shrink based on the content inside without having to specify any widths or heights. A div (with a border) with no width specified will go on forever horizontally. A table (with a border) with no width will stop as soon as the data inside ends. Is there a way to simulate this table behavior using CSS? Thanks
An element of {position: absolute;} or {float: left | right;} will shrink wrap its content if not explicitly dimensioned. There are other approaches, but IE (any version, including 7) has so little support for css that there's no purpose talking about them. There is so seldom reason for that behavior, that it might be a good idea to tell us what you want to accomplish—not how you want to do it. cheers, gary
Can you use <span> since it is not a block element? You might check out International Web Developer's Network as well for some other ideas.
The span would still reside within a block element which would determine its ultimate width. Maybe an issue, maybe not. cheers, gary