Search code examples
htmlsizedhtml

Making a div smaller than its contents


I'm trying to show a div on a webpage, with mostly text.

I would like to know if I can make it smaller so that not all the contents are able to be seen so I later on can make it larger using JavaScript.


Solution

  • Sure, just specify an overflow of hidden.

    EG: in CSS:

    #divid {
       height: 100px;
       overflow: hidden;
    }
    

    That'd make it cut it off after 100 pixels.