Search code examples
cssline-breaks

Line break in a span with defined width?


How can I break a line in a span once the width of the span is reached? I tried max-width, but this did not work, the span is always as long as the text.

Ideas?

Thanks!


Solution

  • By default, <span> elements are 'inline', and will always grow to the size of their content. You need to explicitly declare the <span> to be display: block; or display: inline-block;.