SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist Mr. Brownstone's Avatar
    Join Date
    May 2002
    Location
    Relative
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Defining tab-stop size between <pre> tags?

    I just noticed that no matter what font you assign to a <pre> tag using CSS, IE always thinks that a tab-stop is the same length as that which is displayed using the Courier New font.

    For example; assume the following CSS:

    PHP Code:
    pre.myPRE {
        
    font-familyVerdana;
        
    font-size11px;
        
    line-height1.2;

    ...and the following HTML:

    PHP Code:
    <pre class="myPRE">
    Open:

        
    Disable'Trigger' );
        if ( 
    DelayTime )
        {
            
    bDelaying true;
            
    Sleep(DelayTime);
        }
    </
    pre
    In IE, this produces:

    Image #1:


    And in Mozilla/Netscape:

    Image #2:


    Changing the font to Courier New would give the same tab-stop size (more or less) in both browsers ala Image #1.

    Naturally, for deeply-nested code IE’s horizontal scroll-bar is going to start to grow, so my question is; is there a CSS parameter which you can use to specify the size of a tab-stop? I tried searching the W3C site and all I came up with was a CSS proposal for a tab-stop definition dating back to 1996! Did anything ever materialize out of it, or has something newer succeeded it and I’ve never heard about it?

    Thanks in advance for any assistance.
    Of course, that's just my opinion. I could be wrong.

  2. #2
    SitePoint Wizard Ian Glass's Avatar
    Join Date
    Oct 2001
    Location
    Beyond yonder
    Posts
    2,384
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope.

    I think, that's why most programmers suggest you to use four or so spaces. I'm sure you could use PHP to replace tabs with the spaces--I just don't know how... ;-)

    ~~Ian

  3. #3
    SitePoint Evangelist Mr. Brownstone's Avatar
    Join Date
    May 2002
    Location
    Relative
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for replying. It is as I feared, and I did prepare for it; I have a Regular Expression which will replace tabs with a certain number of spaces, but it creates quite a bit of processor overhead when dealing with large strings, and I would much rather let the browser deal with the formatting.

    Here’s the expression if anyone’s interested:

    For PHP:
    PHP Code:
    $sString preg_replace "/\t/siU""    "$sString ); 
    For JScript ASP:
    Code:
    sString = sString.replace ( /\t/gmi, "    " );
    Of course, that's just my opinion. I could be wrong.


Bookmarks

Posting Permissions

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