0

The following is a screen shot of some content that is part of a form validation in website project that's in the development phase:

enter image description here

This content is currently contained in a div that specifies the width to be 20%. Prior to adding that rule the div stretched horizontally across the entire screen which looked excessive for the short messages that are contained within. Is there a way to let the div (or some other appropriate container) automatically adjust its width to be just wide enough for the content it contains?

knot22
  • 2,648
  • 5
  • 31
  • 51
  • 1
    possible duplicate of [CSS: set width equal to content](http://stackoverflow.com/questions/20383622/css-set-width-equal-to-content) – ChicagoRedSox Mar 22 '14 at 01:28

1 Answers1

2

You can do that with display: inline-block or float. Here is the demo http://codepen.io/anon/pen/vdICu/

calvin
  • 481
  • 4
  • 9
user3448600
  • 3,648
  • 5
  • 17
  • 23