css make div only as wide as it needs to be code example Example: div not larger than its content The solution is to set your div to display: inline-block.