hi guys i am using pre tag for showing any comments that user makes. the parent div tag is set to width 950 px. however the pre tag is overflowing out of the parent div tag. now i dont want to use any scrolling. i just want want the comments to go to the next line automatically whenever its exceeds 950px.. now how can i achieve that.. to be more specific i just want wordwrap for my pre tag at 950px.. please let me know how is that possible.. thanks in advance
Um, don't use <pre> for that? If your box is 950px wide, its content will naturally wrap as needed. If you think you just must use <pre>, tell use why you think so. cheers, gary
Oh, yeah. Don't you realize this is the weekend? And, in the US, it's a holiday weekend (Monday). Wait for a second full work-day before bumping. gary
i would be showing songs lyric from database.. so if i dont use pre tag the lyric doesnt maintain the line break that its supposed to... so i must use pre tag.. however, if i do use pre tag cerain line whice is too wide overflows out of the box... now i could use scroll.. but i dont want scroll. i want the line to wrap itself to the next line.. any help is greatly appriciated...
Try this: pre { white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ } Code (markup): Taken from here , it works but can't guarentee if it's the optimum method. Although you could just use nl2br function (PHP) to format the new lines of the text recieved from the database into HTML line breaks (<br />) and then not use the pre tag.
OK, poetry or verse; that's a good usage. I do wonder, though, how many song lyrics are going to have lines so long; that's about 120 characters at a 16px font size (variable spaced font). I would add the line-break myself, so that it occurs at a reasonable point. cheers, gary