Coding Style Notes

Don't put spaces or other odd characters in files names. This doesn't work on all browsers. If you have to use a URL that ends in a file whose name has spaces in it, replace all the spaces with the characters %20. So the filename 'Blank space.html' becomes 'Blank%20space.html. Then the browser should be able to retrieve it. Better to not use these characters in the filename to start with.

Browsers ignore unknown tags, but don't leave them in. All pages should have <html> and <body> tags, even though browser will show them. Don't use header tags to collect things. Example,

<h2 align="center"> text image </h2>
Use a paragraph tag or a div tag.

Use quotes in attribute values. Even though it will work most of the time, it is a good habit to develop so you don't leave them out when you really need them.

Image tags need height, width and alt attributes. The width and height attributes allow the browser to figure out how much space to allow for the image so it can start displaying the text while the image downloads. This gives the user the impression the page is loading faster. Also, if the picture is bigger than you plan to show it in the page, don't use the width and height tags to make it smaller. Use some image editing software to reduce the image size before you download it. While the appearance may be the same, using the attributes to shrink a picture means that the entire, possibly large, image has to be downloaded before a smaller version is shown. So the user gets to wait as if they were going to see a big picture, but only gets to see the small one.

Combine font tags, multiple attributes per tag. Instead of
<font size="12pt"> <font color="green"> A bunch of green, midsize text </font> %;t;/font>
Do this
<font size="12pt" color="green> A bunch of green, midsize text </font>
If you want the font color for an entire page to change, use the color attribute on the body tag or styles.

Close all the tags. That is, if you have a start tag, put in the end tag as well. Most of the time, if you leave out the end tag, the page will look fine. But sometimes and in some browsers, it won't. Also, it makes it much easier to use style properties when the tags are closed. A few exceptions include br and hr tags.

IE shows form elements even if no form tag. So you can't tell just be looking at the web page that the form WON'T work. Even without the action CGI program working, you can test this by clicking or typing some things and hitting the reset button. If nothing happens, you don't have a form tag. It might look ok in the browser and STILL BE WRONG!

Don't use web page editors. YOU CAN'T FAKE THIS STUFF. You need to practice working with the elements by hand so you understand them better. Once you do, in real life you should use whatever tools you can find to speed up your work.

Don't use spaces in form element names. It will cause problems in validation. Input tags need a type attribute. It appears that some browsers default to text but don't assume this.

Use descriptive names. If you are creating a select element about which state the user is in, it is better to call it state rather than select3.