Section 6. About Proper HTML Coding

6. About Proper HTML Coding

BEFORE YOU BEGIN

2 Use HTML Tags


When you start coding pages, you'll notice that they can get very messy looking very quickly. So messy looking, in fact, that unless you pay attention to keeping everything neat, clean, and proper, you'll soon lose your way. This is especially a problem if you come back to edit a page later. If you coded the original page willy-nilly, it will be very difficult for you to recode it.

Because of that, it's a good idea to pay attention to your coding stylethe way that you place HTML code on a page. Code your page neatly and in an organized fashion and you'll save yourself tremendous amounts of time and angst.

Follow this advice, and you'll go a long way toward creating clean code that's easy to follow and edit:

  • Use comments on your page There are a number of reasons you might want to use comments on your page. You might want to remind yourself why you coded something a certain way, or remind yourself to change content. And you might also use comments to describe a certain section of the pagefor example, a complex tableso that it's easy to locate when you need to edit your page. To put a comment in a page, start it with <! -- and end it with -- > like this: <! -- This is a comment -- > .

  • Indent your code to make it easier to follow Some coders find that if they indent certain portions of their code, it can be much easier to follow and edit. This is particularly true when editing tables (see Chapters 6, "Using the Advanced Editor for Building Web Pages," and 9, "Organize Text with Tables and Rules"), which can sometimes make anyone go cross-eyed. Inserting indentations won't affect how your page looks, but it will make it easier to edit.

  • Color code your tags Another way to make it easier to edit your code is to color code your tags. This way, you can more easily pick out relevant information. Many HTML editors let you do color coding of tags.

  • Be consistent in your use of upper- and lowercase Tags can be either uppercase or lowercase. Choose which you prefer, but don't mix the twoit'll be harder to follow your code.



Sams Teach Yourself Creating Web Pages All in One
Sams Teach Yourself Creating Web Pages All in One
ISBN: 0672326906
EAN: 2147483647
Year: 2006
Pages: 276

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net