Web Analytics Made Easy -
StatCounter controling <pre> width - CodingForum

Announcement

Collapse
No announcement yet.

controling <pre> width

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • controling <pre> width

    I have text that is formated with <pre> going in to a <div> which has its width constrained to 80%. If I want the text not to bust through the <div> and streem endlessly right, what should I do?

    -Thanks!

  • #2
    You could set overflow:hidden or overflow:scroll for the pre tag. The first will hide what wont fit while the second will add a scrollbar to the pre tag when it is needed.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

    Comment


    • #3
      Have you tried giving the <pre> a width (possibly of 80%) too?
      markaylward.co.uk

      Comment


      • #4
        the thing is, that I want the text to form a column, as one might do by placing it inside a div.

        I tryed the width on the pre tag itsef already, didnt do anything.

        Any other ideas?

        Comment


        • #5
          I'm guessing that you want new-line and white-space formatting to be preserved but for wrapping to also occur? You would use white-space: pre-wrap for that. Support for it is pretty poor though.

          Resources:

          Comment


          • #6
            Ahh it worked!

            Code:
            pre{
            	font-family:Georgia, "Times New Roman", Times, serif;
            	white-space: pre; /* CSS2 */
            	white-space: -moz-pre-wrap; /* Mozilla */
            	white-space: -hp-pre-wrap; /* HP printers */
            	white-space: -o-pre-wrap; /* Opera 7 */
            	white-space: -pre-wrap; /* Opera 4-6 */
            	white-space: pre-wrap; /* CSS 2.1 */
            	white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
            	word-wrap: break-word; /* IE */
            	}
            that setup gleened off one of your resources did the trick.
            Thanks!

            Comment

            Working...
            X