Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[TIP] Indent Table Elements
mashby's Avatar
mashby
Join Date: Jan 2002
Posts: 736

Married, no kids yet, born in Louisiana and I'm hooked on the television show "24."

Nashville, TN - USA
Show Printable Version Email this Page Subscription
mashby mashby is offline 09-09-2002, 10:00 PM

Table problems are one of the most common problems that people run into when editing their templates. Forget to close a tag and your entire site can become crippled. To help fix this problem before it starts, I recommend that you indent each element when using tables. By simply adding a tab, or a few spaces to your code, you can make it easier to see if there's a problem with your code.

Compare the following two code samples and you'll see what I mean:

Code:
<!-- without indents -->
<table><tr>
<td>hello world</td></tr>
</table>
<!-- /without indents -->
Code:
<!-- with indents -->
<table>
	<tr>
		<td>hello world</td>
	</tr>
</table>
<!-- /with indents -->
Which is easier to read? When I try and help someone with their code, one of the first things I do is reformat their code with indents. If there's a problem with a missing tag, you can be sure that I can find it in a jiffy with this method.

You'd be surprised at what a difference something as simple as this can make.
Reply With Quote
  #12  
Old 10-01-2002, 09:30 AM
Tony G's Avatar
Tony G Tony G is offline
 
Join Date: Nov 2001
Location: Melbourne, Australia
Posts: 8,357
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can live with both, but I find it a little easier. It don't really matter anyway much to me.
Reply With Quote
  #13  
Old 10-01-2002, 11:53 AM
imported_plattopus imported_plattopus is offline
 
Join Date: Jun 2002
Location: Melbourne, Australia
Posts: 77
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah it's usually easier... especially when you're dealing with a lot of nested tables. If you see a big jump in indents, that suggests you've either missed a few closing tags, or forgotten them.

Example:

Code:
<table>
<tr>
<td valign="top">
This is some text
</td>
<td>
<table width="100%">
<tr>
<td>
Some more text
</td>
</tr>
<tr>
<td colspan="2">
This is yet more text
</td>
</tr>
</table>
It could be hard to notice errors in code like this (but far more complex, I only used this as an example)... this is much easier:

Code:
<table>
  <tr>
    <td valign="top">
      This is some text
    </td>
    <td>
      <table width="100%">
        <tr>
          <td>
            Some more text
    </td>
  </tr>
  <tr>
    <td colspan="2">
      This is yet more text
    </td>
  </tr>
</table>
You can see the big jump in space between the text and it's ending TD tag.
Reply With Quote
  #14  
Old 10-01-2002, 12:11 PM
Tony G's Avatar
Tony G Tony G is offline
 
Join Date: Nov 2001
Location: Melbourne, Australia
Posts: 8,357
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I agree, I prefer the second way but I don't mind. I mean I can still spot errors without the indents but it could be harder.
Reply With Quote
  #15  
Old 10-18-2002, 01:25 PM
Christoff's Avatar
Christoff Christoff is offline
 
Join Date: May 2002
Location: Poland
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Plattopus: upload your files in ASCII mode and there will be no problem with character coding
I often edit files on windows and after upload there is no diffrence from the one made on BSD
Reply With Quote
  #16  
Old 10-19-2002, 06:37 AM
imported_plattopus imported_plattopus is offline
 
Join Date: Jun 2002
Location: Melbourne, Australia
Posts: 77
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is a difference, it might just be luck that both of the programs you used are configured similarly.
Reply With Quote
  #17  
Old 10-23-2002, 10:01 AM
mashby's Avatar
mashby mashby is offline
 
Join Date: Jan 2002
Location: Nashville, TN - USA
Posts: 736
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Good points plattopus. My text editor intreprets the Tab and then inserts the number of spaces that you've set.

For those of you editing in multiple OS's, plattopus' idea about using spaces is a good one.

Either way, indention can help.
Reply With Quote
  #18  
Old 10-24-2002, 03:30 AM
imported_plattopus imported_plattopus is offline
 
Join Date: Jun 2002
Location: Melbourne, Australia
Posts: 77
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've set my text editor (Edit Plus 2) to do the same thing... that way, I can use the TAB key (which is far more convenient than pressing space 4 times) and it will insert 4 non-breaking spaces instead of a tabspace.

But the point is, indentation is a MUST for readability.
Reply With Quote
  #19  
Old 10-24-2002, 04:35 PM
mashby's Avatar
mashby mashby is offline
 
Join Date: Jan 2002
Location: Nashville, TN - USA
Posts: 736
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's the same text editor I use!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:06 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04428 seconds
  • Memory Usage 2,280KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete