|
|
|
| Web Hosting Guide |
Good Comments Make Good Html., Commenting makes HTML easier to write. |
Feb 24 2005, 01:03 AM
Post
#1
|
|
|
Absolute Newbie Group: Admin Posts: 888 Joined: 20-February 05 From: Indianapolis, Indiana, USA (Midwest) Member No.: 2,714 myCENTs:35.43 |
Good Comments Make Good HTML.
Commenting makes HTML easier to write. This is a spin off from another article I wrote entitle Good Comments Make Good Scripts. While the code is different, the concepts for comment are the same. Enjoy! Disclaimer! This tutorial is intended to be used to show the benefites of commenting your HTML in order to write clean, easy to read code. For the purpose of this tutorial, HTML, XML, XHTML validating is not taken into consideration. While I will make an effort to point out non-standardized code, validation has never been my priority and I'll probably miss a few things. Always run your HTML through an HTML validater to check for compatability issues. Reasons for commenting HTML: - Makes your code easier to trouble shoot. - Add a friendly reminder of things you wanted to include in your page. - Allows you to save information about the page without showing the general public. - Provides a way of giving yourself credit for creating a nice page. - Used as instructions for JavaScript and other client side script usage. Getting Started! ------------------------------------------------------------------- An HTML comment tag is quite simple, everything inside the tag is hidden from the browser and is considered to be the comment. The HTML comment tag is: CODE <!-- --> Example with a comment: CODE <!-- Here is a comment! --> Example of a multi-line comment: CODE <!-- I would like take this oppurtunity to descript the color of the sky. The color of the sky is a unique shade of the color blue. Unless of course there is overcast and then its more like gray. Then again in the fog evreything is white. Appearently the sky is multicolored! --> Now lets talk about when and where to comment yout HTML. The first place I like to add a comment in a web page is at the beginning of a table. Example: CODE <!-- Start table 1 here - 3 rows high and 4 columns wide --> <TABLE BORDER="1"> <TR> ... Another really good use for a comment in a table is when a cell spans multiple rows or columns. Say that you have a table that is 4 rows and 4 columns and you want one really large cell in the middle. Attachment:
table.JPG ( 5.56K )
Number of downloads: 94Comments will help you keep track of where cells used to be. Example: CODE <!-- Table 1 - 4 rows high and 4 columns wide --> <TABLE BORDER="1"> <TR> <TD> Cell 1-1 </TD> <TD> Cell 1-2 </TD> <TD> Cell 1-3 </TD> <TD> Cell 1-4 </TD> </TR> <TR> <TD> Cell 2-1 </TD> <TD COLSPAN="2" ROWSPAN="2"> Cell 2-2 </TD> <!-- Cell 2-3 would have been here --> <TD> Cell 2-3 </TD> </TR> <TR> <TD> Cell 3-1 </TD> <!-- Cell 3-2 would have been here --> <!-- Cell 3-3 would have been here --> <TD> Cell 3-4 </TD> </TR> <TR> <TD> Cell 4-1 </TD> <TD> Cell 4-2 </TD> <TD> Cell 4-3 </TD> <TD> Cell 4-4 </TD> </TR> </TABLE> <!-- End table 1 here --> I use this frequently as I tend to get confused when I start spanning cells. Occasionally I have very lengthy forms that I need to comment in order to keep track of what's what. Example: CODE ........ <INPUT TYPE="TEXT" NAME="Var126" SIZE="25"> <!-- This is the 126th input variable for this form --> ........ Comments are great for saving places for all of our content. For example, say you have an advertiser with a banner and just below his banner you have room for one more banner, just comment that this is where you can place a new add. Example: CODE <!-- Start Foo.com's Banner Code Here--> <A HREF="http://www.foo.com/foo_sale.html"><IMG SRC=="http://www.foo.com/foo_sale.gif"></A> <!-- End Foo.com's Banner Code Here --> <!-- To Quit Losing Money Place Advertisement Here!;) --> <H1><CENTER>My Title Here</CENTER></H1> This works great for code you don't know how to write yet as well. Example: CODE Fill in the form below to order your free money:<BR> <!-- Use some of my money surplus to learn how to add an HTML form here! --> If you have any questions <A HREF="mailto:jdoe@foo.com">Email Me!</A><BR> Okay here's an example of what didn't work: CODE <FONT COLOR="RED"> <!-- Yellow font does not work here you already tried it three times! --> Another method I use to help keep track of the flow of HTML is indenting. Example: CODE <HTML> <HEAD> <TITLE> My Title. </TITLE> </HEAD> <BODY> Body content here. </BODY> </HTML> See how easy it is to check if all of your closing tags are present. This is great if you have tables inside of tables, but will always make reading the code a lot easier. You may have noticed that all of my tags use uppercase type. I have found that this makes picking the tags out from all of the content text much easier. When I learned HTML, tags were always like this but now validation requires lowercase type as I understand it. You will have to decide for yourself how best to write your code but I suggest that you keep in mind the possibility that someday you may need to convert your HTML to another markup language. Tells us about your suggestions for commenting. Happy coding, vujsa |
|
|
|
Posts in this topic
vujsa Good Comments Make Good Html. Feb 24 2005, 01:03 AM
miCRoSCoPiC^eaRthLinG cool.. good followup on that Commented Coding arti... Feb 24 2005, 11:17 AM
vujsa Something I touched on breifly in this article but... Feb 25 2005, 04:06 AM
jcguy Can commenting in the coding be done in php and pe... Feb 25 2005, 12:54 PM
vujsa QUOTE (jcguy @ Feb 25 2005, 07:54 AM)Can comm... Feb 25 2005, 10:51 PM
Spog QUOTE (vujsa @ Feb 25 2005, 06:51 PM)in fact,... Mar 13 2005, 03:58 AM
vujsa Actually, php allows multiple comment tags.
All o... Mar 16 2005, 12:22 AM
ChronicLoser hmm...i agree that comments are useful in html...b... Mar 16 2005, 12:42 AM
moonwitch QUOTE (vujsa @ Feb 24 2005, 02:03 AM)You may ... Mar 16 2005, 03:22 AM
h3lium for simple pages, i always find it easier to not u... Aug 10 2005, 07:07 PM
twitch Although a lot of people are against validation, i... Oct 29 2005, 07:04 PM
twitch QUOTE(guy @ Oct 29 2005, 07:04 PM)Although a ... Oct 31 2005, 04:40 AM
vizskywalker Also, if you are using XHTML, be sure to read the ... Oct 30 2005, 09:25 PM
Quatrux I almost never use comments in html unless i want ... Oct 30 2005, 10:47 PM
Logan Deathbringer Although I don't comment my HTML like I should... Oct 31 2005, 03:17 AM
minnieadkins Comments make the code. HTML comments aren't ... Oct 31 2005, 06:48 PM![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
98 | Cookiemonster | 15,294 | 20th March 2010 - 02:19 PM Last post by: Ahsaniqbal111 |
|||
![]() |
10 | nakulgupta | 5,190 | 20th March 2010 - 02:15 PM Last post by: Ahsaniqbal111 |
|||
![]() |
28 | Ed :P | 9,701 | 16th March 2010 - 07:36 PM Last post by: iG-Luke |
|||
![]() |
20 | dhanesh | 15,702 | 16th March 2010 - 03:15 PM Last post by: iG-maze |
|||
![]() |
27 | firefoxsilver9 | 31,645 | 5th March 2010 - 03:36 AM Last post by: iG-Vivek Lohia |
|||
![]() |
116 | spickid101 | 24,901 | 1st March 2010 - 10:21 PM Last post by: iG-silentdeath16 |
|||
![]() |
46 | broli | 9,553 | 22nd February 2010 - 08:36 PM Last post by: iG- |
|||
![]() |
3 | jord2 | 1,800 | 18th February 2010 - 02:13 AM Last post by: iG-Tariq Khan |
|||
![]() |
12 | Zeeshan Hashmi | 5,197 | 15th February 2010 - 09:59 PM Last post by: iG-thewind |
|||
![]() |
3 | FirefoxRocks | 274 | 14th February 2010 - 03:52 AM Last post by: mastercomputers |
|||
![]() |
45 | wua05 | 6,545 | 14th February 2010 - 12:28 AM Last post by: iG-StayGold |
|||
![]() |
6 | Eggie | 1,532 | 10th February 2010 - 01:29 AM Last post by: iG-james |
|||
![]() |
12 | Nqon | 4,608 | 9th February 2010 - 02:46 PM Last post by: iG- |
|||
![]() |
25 | clovis | 10,861 | 8th February 2010 - 08:54 AM Last post by: iG-whiteshark0121 |
|||
![]() |
1 | wutske | 2,150 | 1st February 2010 - 09:44 AM Last post by: iG-weGIF |
|||
|
Lo-Fi Version | Time is now: 22nd March 2010 - 06:25 AM |
© 2010 AstaHost: Free Web Hosting & Technical Discussion, Free Web Hosting. a member of xisto.
Powered by Invision Board. Skin: IPB Forum Skins
Expand / Collapse Navigation


Feb 24 2005, 01:03 AM








