WordPress.org

Ready to get started?Download WordPress

Forums

Does WordPress Break the `PRE` Element? (9 posts)

  1. brentontherefore
    Member
    Posted 1 year ago #

    As we all know, the HTML <pre> tag means preformatted text, and is used to do things like preserve the white-spaces in preformatted text, so that if I use spaces to align some text like this:

    0
     1
      2
       3
        4
         5
          6

    it will look like that, instead of letting HTML do it's thing to collapse it and making it look like this:

    0 1 2 3 4 5 6

    or this

    0
    1
    2
    3
    4
    5
    6

    So why does WordPress strip out concurrent spaces before even sending code to the browser, even inside a <pre> tag? When I view the source and look at my <pre> element, the white spaces aren't there, WordPress has entirely removed them. HTML never has a chance to preformat it, the spaces are gone. This defeats the purpose of <pre> altogether. Yet I've seen people using the <pre> tag on WordPress sites and their spaces show up fine. Is this something recently broken in 3.5.1??

  2. Rajesh Soni
    Member
    Posted 1 year ago #

    Have you tried using <xmp> instead?

  3. brentontherefore
    Member
    Posted 1 year ago #

    That tag is not valid HTML. I believe it wasn't even valid in HTML 4.01.

  4. brentontherefore
    Member
    Posted 1 year ago #

    I have a similar question on wordpress.stackexchange with a bounty of +50 if you can answer it. It expires soon though.

    http://wordpress.stackexchange.com/questions/90065/preserve-white-space-in-page

  5. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    Just tested it in twentytwelve - worked fine. But be sure you are using "text" editor and not switching between the "text" and "visual" editors as that WILL strip code.

  6. brentontherefore
    Member
    Posted 1 year ago #

    I'm definitely just using the HTML text editor. twentytwelve is a theme--which version of WordPress are you using?

  7. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    3.5.1

  8. brentontherefore
    Member
    Posted 1 year ago #

    Agh. This is so frustrating--why does yours work but mine does not?

  9. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    Dunno, what theme are you using? Have you tried deactivating your plugins?

Topic Closed

This topic has been closed to new replies.

About this Topic