Results 1 to 6 of 6

Thread: Use of <PRE>

  1. #1
    Star Lounger
    Join Date
    Sep 2003
    Location
    Texas, USA
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Use of <PRE>

    I still use <PRE> for my web site. I have noticed that the text flows way off the screen to the right. Is there any way to correct this without use of <HR> or hitting ENTER?
    Thanks!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Use of <PRE>

    The purpose of <pre> ... </pre> tags is to display text exactly as entered, including all spaces (HTML normally suppresses multiple spaces). So you're responsible for breaking lines yourself. If you don't want to do that, you shouldn't use <pre> ... </pre> tags. You can use non-breaking spaces &nbsp;* if you want to insert multiple spaces.

  3. #3
    Star Lounger
    Join Date
    Sep 2003
    Location
    Texas, USA
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use of <PRE>

    Thank you, but I used to NOT have this problem with my web pages, and that is why I asked. The text would stay within the width of the monitor WITHOUT entering any breaks. I am unable to determine what I am doing differently. So, back to the drawing board...

  4. #4
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Use of <PRE>

    You could use the alternative and use the <code> tag which does allow wrapping without the need for </br> or </hr> tags to format.

    If you are happy (or adventurous) you could try using CSS to do the formatting for you.

    Put this code in a HTML file and see how it displays, I have set it to be 50nd with a colour background purely to show how the format changes:

    <pre><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Using the <code> tag with CSS</title>
    <style>
    .wrap{
    background-color: #99FFCC;
    width: 50%;
    }
    </style>
    </head>

    <body>
    <div class="wrap">
    <code>Lorem ipsum dolor sit amet,consectetuer adipiscing elit. Donec sollicitudin libero id elit.
    Sed euismod nonummy neque.Nam dignissim urna vel urna. Nunc aliquet.Nunc vel dui mattis magna varius condimentum.
    Etiam lacus enim, aliquam ultricies,
    luctus ut, placerat id, lectus.
    Vestibulum laoreet commodo tortor.

    </code>
    </div>
    </body>
    </html>
    </pre>


    Adjust the latin filler text to different lengths on the line and you will see it wrap. I haven't done it here as it affects the view in the Lounge. HTH
    Jerry

  5. #5
    Star Lounger
    Join Date
    Sep 2003
    Location
    Texas, USA
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use of <PRE>

    Thank you, Jezza. You may have given me the "oomph" to start learning CSS.

  6. #6
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Use of <PRE>

    No probs, if you want to try something else, and be able to provide you with more flexibility you can change the CSS style to use the white-space method which uses the pre format, like so:

    <pre><style type="text/css">
    .PreTag

    {
    white-spacere;
    width: 50%;
    background-color:#99FFFF;
    }
    </style>
    </pre>

    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •