Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS 2.1: Wrap Text Inside Div

Tags:

html

css

I have HTML and CSS as shown in http://jsfiddle.net/Lijo/Ydjde/

The problem is the text inside div is not confined to the div. It breaks the div and write. How can we wrap the text inside the div itself with following features?

• The full text will be readable

• It will not break the div

Is there a way to use it in CSS 2.1? I believe word-wrap is CSS 3.0 feature.

Note: I have width defined as width:100px; and width:30px; for the first and second divs

Note: The span is generated from ASP.Net Label control. Hence we cannot change/replace the span. The problem is to be resolved using CSS.

 <span id="detailContentPlaceholder_Label1">25123456789</span>

enter image description here

Reference:

  1. Word-wrap in an HTML table
  2. CSS word-wrapping in div
  3. CSS3 word-wrap Property
like image 306
LCJ Avatar asked Dec 08 '22 21:12

LCJ


2 Answers

word-wrap: break-word; is your friend. See your updated JSFiddle.

like image 184
Roddy of the Frozen Peas Avatar answered Jan 10 '23 17:01

Roddy of the Frozen Peas


do you mean word-wrap: break-word?

http://jsfiddle.net/PhRKh/

(edit: oops, didn't see the other answer)

like image 40
Roman Avatar answered Jan 10 '23 15:01

Roman