Kris Kris - 4 months ago 8
CSS Question

Making child elements of a div inline

I am looking for the CSS property to make elements inside a div inline.

What property do I need to add to the parent

.container
to make the child elements
<div><span>
inline?

I don't want to apply a class directly to the children.

<div id="container">
<div></div>
<span></span>
</div>


Thanks,
Kris

Answer

Do you mean all the children? Then use

#container * {
   display: inline-block;
}

If you mean only the direct children (so not the elements nested in the children) use

#container > * {  
   display: inline-block;
}