Lesson 5 - HTML Miscellanea

Even if you've mastered putting in your tags and formatting your code, there are still some HTML odds and ends that are good to know.

Comments

One of the most useful tags in HTML is one you'll never see displayed. The comment tag contains any information you want to write in the code but you don't want to display. It is most commonly used to write in notes about your code. It becomes really useful when writing long blocks of code or create code for other users. It is written in a unique way:

<!-- My comment goes in here. -->

Whatever is written within the opening <!-- to the closing --> will be completely ignored by the browser in rendering the page, but will be visible within the source code. This is another great way to stay organized.

Special Characters

Because all code is written with the characters on your keyboard, some characters are specially reserved for code, such as "<" and ">." In code, even more than one white space won't show. This is why there are special characters in html. These are little bits of code that represent a single character that is already covered by code. All of them begin with the ampersand (&) character and end with a semicolon (;).

Here are a couple examples:

&nbsp; - an extra whitespace
&amp; - & (ampersand)
&ndash; - – (n dash)
&quot; - " (quotation mark)

Check out this page for a complete list.

Email to

We know how to make links to websites already. Using the same method, it is also possible to link to an email address. It is written like this:

<a href="mailto:youraddress@yoursite.com">Link goes here</a>

When this link is clicked, it will open up the default mail client with the "To:" line prefilled with the recipient's address.

Making Your Link Open In A New Window

If you are linking from page to page within your site, you generally want each page to load in the same window. If you are linking to an external site, sometimes it makes more sense to open the link in a new window. This is especially the case if you want to have a link but you don't want to drive traffic away from your site. Linking to a new window is an attribute to the anchor tag, it is written like this:

<a href="http://www.mylink.com" target="_blank">Link goes here</a>

Browser Issues

It is important to note that all browsers render HTML very similarly, but not exactly the same. Each browser has slightly different rules for how each tag is rendered. It is always a good idea to check your site in as browsers as possible to make sure it renders properly on each. The differences between browsers are too many to list, but basic discrepencies will become clear over time. You should always check your site in the following browsers: Firefox, Internet Explorer, Safari, and Netscape.

Back to Lesson 4 . On to Lesson 6