Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Silly Syntax Queston  (Read 4953 times)

0 Members and 1 Guest are viewing this topic.

Aegis

    Topic Starter


    Expert

    Thanked: 67
    • Yes
    • Yes
    • Brian's Mess Of A Web Page
  • Experience: Experienced
  • OS: Windows 10
Silly Syntax Queston
« on: April 06, 2008, 04:10:33 PM »
Is it better to include tags on the same line as the text, as in:

<center>Hello!</center>

or is it better to siparate them, as in:

<center>
Hello!
</center>

The former saves keystrokes and vertical space, but the latter has an appeal to my feeble brain.

I suspect that coding is a mix of both -- there are times when a syntax will lend itself to one format or the other.

What are your experiences?



"For you, a thousand times over." - "The Kite Runner"

Computer Hope Admin

  • Administrator


  • Prodigy

    Thanked: 248
    • Yes
    • Yes
    • Yes
    • Computer Hope
  • Certifications: List
  • Computer: Specs
  • Experience: Guru
  • OS: Windows 10
Re: Silly Syntax Queston
« Reply #1 on: April 06, 2008, 05:53:47 PM »
Either way of course is going to work but I'd highly recommend the first syntax for the below reasons.

1. All serious HTML writers and programs do it this way.
2. Makes it easier to read
3. Especially in the case of your <title> tag example, having it on multiple lines may cause your page to not be indexed properly by search engines by having it on multiple lines.
4. Saves disk space. You're probably thinking two extra character returns (in this example) isn't that much but when you times that by thousands of pages it actually is more disk space which also adds to your overall total bandwidth costs which can be pricey when you're doing several gigs a day. *
5. A lot easier to Search and replace text if it's on one line. For example if you wanted to change or add to the title of every page with one click of a button. Of course more sophisticated means of search and replace could still handle this type of syntax, but some may not and would help ease the process.

Those are what I thought up off the top of my head, I'm sure there are more but stick with the first syntax in the case of most HTML. The only real place you can't get away with single line syntax is with most <script..></script> code since JavaScript and other languages can really get confused with a single line of code.

* Good example of saving code. I recently adjusted the syntax structure and cleaned up my code on several thousand Computer Hope pages. Doing this I was able to removed 32MB of extra data that was just used from crap syntax and extra HTML that is no longer needed.


Everybody is a genius. But, if you judge a fish by its ability to climb a tree, it will spend its whole life believing that it is stupid.
-Albert Einstein

Aegis

    Topic Starter


    Expert

    Thanked: 67
    • Yes
    • Yes
    • Brian's Mess Of A Web Page
  • Experience: Experienced
  • OS: Windows 10
Re: Silly Syntax Queston
« Reply #2 on: April 06, 2008, 07:21:13 PM »
32 MB?  I know that doesn't seem like much in our giga / terabyte world, but that's pretty huge!  Well, shave my head and call me "Grasshopper."

Thank you for your kind reply.  That's why I decided to ask, now:  so I can make the "single line" syntax a habit now, rather than have to unlearn a bad habit -- may as well keep THAT list as short as I can!   ::)


"For you, a thousand times over." - "The Kite Runner"

Computer Hope Admin

  • Administrator


  • Prodigy

    Thanked: 248
    • Yes
    • Yes
    • Yes
    • Computer Hope
  • Certifications: List
  • Computer: Specs
  • Experience: Guru
  • OS: Windows 10
Re: Silly Syntax Queston
« Reply #3 on: April 06, 2008, 08:01:54 PM »
That's 32MB of just text and yes it's not a ton, but it significantly reduced my total bandwidth (reduction of around 20GB of data transfer) for each month saving me money. :) Also helps with load times, the average user spends 3 seconds looking at a page. The faster it loads the better.
Everybody is a genius. But, if you judge a fish by its ability to climb a tree, it will spend its whole life believing that it is stupid.
-Albert Einstein