How can I make a div not larger than its contents? by Tarik The solution is to set your div to display: inline-block.