Announcement

Collapse
No announcement yet.

White space in HTML?

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

    White space in HTML?

    From time to time, I find code in page templates such as this:
    Code:
     <div class="column one-fourth"><span data-icon="&#xe0e6;"></span><strong class="hide medium-show">ORDER CONFIRMATION</strong><strong class="medium-hide">STEP 4</strong></div>
    -- where someone has been careful not to leave any white space in the viewable text; spaces are used only inside the tags. I find this hard to read and edit. Usually I just live with it, but occasionally I have added a few white-space characters, in order to break one long line into several shorter ones that are easier to work with. It didn't seem to make any difference when I viewed the page on my screen.

    Am I missing something? Is there an important reason to write code with no white space, or was it just a preference by the original author? Or maybe something left over from earlier versions of the HTML standard, or for compatibility with older browsers?

    Thanks --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    could be also attributed to what happens to code when copied and pasted between operating systems using different line breaks, or when, for example, you edit a memo field in 'Batch Edit Mode' and it wipes out all CR/LFs

    white space should never be an issue with either proper HTML or mivascript/SMT code.
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      Probably doesn't apply for these scenarios? For both SMT and modules, I have had issues with white space regarding JS and JSON where the extra space at the end of the line before a carriage return needed to be removed. I probably never had time, but never tracked down more info. Thinking out loud though, does white space potentially affect the compiler?

      Scott
      What help do you need today!
      Interactive Design Solutions http://www.southbound.com
      MivaMerchant Business Partner | Certified MivaMerchant Web Developer
      My T-shirt Collection is mostly MivaCon T-shirts!!
      Competitive Rates, Popular Modules, and Integrations:
      Product Copy | AutoBaskets | Waitlist Integration| Wholesale Integration

      Comment


        #4
        Originally posted by Bruce - PhosphorMedia View Post

        white space should never be an issue with either proper HTML or mivascript/SMT code.
        Hmmmm...then I guess there are some modules out there that may need some work...

        Leslie Kirk
        Miva Certified Developer
        Miva Merchant Specialist since 1997
        Previously of Webs Your Way
        (aka Leslie Nord leslienord)

        Email me: [email protected]
        www.lesliekirk.com

        Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

        Comment


          #5
          Just to be clear, when I say it wont effect HTML of SMT, I'm talking about cases like

          <div>





          <p> Something





          </p>


          And

          <mvt:assign name="l.foo" value="'This that

          the other one

          here too' $

          l.somevalue$'


          what'
          "/
          >

          other breaks could fail like

          <mvt:assign name="l.somevalue " value="l.someothervalue"/>

          Bruce Golub
          Phosphor Media - "Your Success is our Business"

          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
          phosphormedia.com

          Comment


            #6
            I was thinking more along the lines of those kazillion lines of whitespace before you even get to the first line of code for the page. I guess that's something different.
            Leslie Kirk
            Miva Certified Developer
            Miva Merchant Specialist since 1997
            Previously of Webs Your Way
            (aka Leslie Nord leslienord)

            Email me: [email protected]
            www.lesliekirk.com

            Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

            Comment


              #7
              yea, that's from, along with other things, modules running function calls without whitespacecompressed turned on when there is actually nothing to output...or something like that. not really the end of the world, but annoying.
              Bruce Golub
              Phosphor Media - "Your Success is our Business"

              Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
              phosphormedia.com

              Comment


                #8
                In Miva templates, I often see code like this snippet from a client's global header:
                Code:
                 <li class="mini-basket"><a href="&mvte:urls:BASK:auto;" rel="nofollow" id="js-mini-basket"><span data-rt-icon="&#x30;"></span>(<span id="js-mini-basket-count">&mvte:global_minibasket:basket_count;</span>)</a></li>
                Two spans inside a link inside a list item, and no white space at all between the tags. I find this hard to work with, because the lines get wrapped to fit the screen, and they don't match the indentation of the adjacent lines. When I'm studying a piece of code, I'm more likely to miss something important if multiple tags are spliced together into one long, dense block.

                On the other hand, when looking at the LSK, we see things like this:
                Code:
                 <MvIF EXPR = "{ [ g.Library_Filename_DB ].StoreList_Load_All( l.stores ) NE 1 }">
                Space characters everywhere, many more than necessary; and lots of tabs and blank lines too. I'm pretty generous with white space myself; I think it adds clarity. But I've been writing software since the 70s, and I think this is the only place I've ever seen people put a space on the inside of parentheses and square brackets. Since Miva puts lots of white space in scripts, I wondered if there's a reason why they avoid it in templates.
                Kent Multer
                Magic Metal Productions
                http://TheMagicM.com
                * Web developer/designer
                * E-commerce and Miva
                * Author, The Official Miva Web Scripting Book -- available on-line:
                http://www.amazon.com/exec/obidos/IS...icmetalproducA

                Comment


                  #9
                  It depends. Those <span class="this"></span> tags are generally used with javascript/jquery append() or add() commands that can insert content into the span from the dom. If coded correctly, they are also pre-classed as display:none; so a space has no meaning. However, when the content (for example, basket count) is added to via those script commends results in a <span> 4</span> or <span>4 </span>, that space can make the intended display incorrect. So, generally, it has to be written without a space. however, I don't think line breaks, which are ignored by HTML matter so you can line break those lines.
                  Bruce Golub
                  Phosphor Media - "Your Success is our Business"

                  Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                  phosphormedia.com

                  Comment

                  Working...
                  X