VideosMy ProjectsProgramming BlogGallery
  1. Home
  2. Blog
  3. How to make a div fit the size of its children
Programming Blog

Atom/RSS Feed

css

How to make a div fit the size of its children

css

You can make a div fit the size of its children by using display: inline-block

Example Usage

<div style="display:inline-block"><!--  this div will be same size as its child -->
    <p style="width:200px;height 500px;">some content</p>
</div>

Using display:inline-block

some text
hello

Without display:inline-block

some text
hello
Join my mailing list