Your Name Here
Internet Services
Question?
Our Products
- Domain Registration
- Hosting Packages
- 50mb Web Hosting
- 100mb Web Hosting
- 200mb Web Hosting
- Micro Web Hosting
- Starter Web Hosting
- Standard Web Hosting
- Pro Web Hosting
Our Features
HTML Tutorial
Chapter 8: Clean Code, Comments & Escape Codes
Clean Code
Clean code means that your HTML coding follows all specifications. Here are a few ways to keep your code clean:
-
Don't type special characters into your code, instead type their escape code. Many characters should NEVER be typed directly into HTML code... for example the "<", ">", the "©", "&", and the " itself. Instead, type &escape_code; (Ampersand, Escape Code for Character, then a semicolon). For these 5 characters, here are the escape codes
- For the < type <
- For the > type >
- For the © type ©
- For the & type &
- For the " type "
- Use quotes around values in attributes. For example, if you want a horizontal rule that is half of the screen width, type <hr width="50%"> rather than <hr width=50%>, or if you want one that is size 5 type <hr size="5"> rather than <hr size=5>.
-
Don't overlap tags. Overlapping occurs when Tag A starts, Tag B starts, Tag A closes, then Tag B closes. This will cause errors in sensitive browsers. For Example, it will not render correctly in Navigator 4.0 Beta1, Netscape purposefully built into the browser so developers could catch errors. Examples:
-
Wrong Way (Overlaps):
<font size=+1><b>This is Bold and One Font Size Bigger</font></b>
Right Way (Doesn't Overlap):
<font size=+1><b>This is Bold and One Font Size Bigger</b></font> -
Wrong Way (Overlaps):
<a href="here.html"><i>This link is italicized</a></i>
Right Way (Doesn't Overlap):
<a href="here.html"><i>This link is italicized</i>>/a>
-
Wrong Way (Overlaps):
The Comment Tag
If you are writing an HTML document, sometimes you may want to put little reminders to yourself with your code so that you will be able to interpret your coding better. A comment will not appear in a web browser when the page is displayed... it is only visible when the source code is viewed. You start commented text with <! - - and end it with - - >.
Your Own HTML Page
Add the following red text to your HTML page ("index.html")
<html>
<head>
<title> My First Webpage </title>
</head>
<!-- The body starts here - and a background image is loaded -->
<body background="bg.jpg">
<!-- This is a heading, in blue -->
<center><h1><font color="blue">YOURNAME's Home Page</font></h1></center>
<p>This is the home page of <b>YOURNAME</b>.</p>
<!-- My name and the two images are all part of a link - which is a "mailto" link -->
<p>E-Mail me by clicking the mail image. <a href="mailto:youremailaddress"><img src="mail.png" border=0></a></p>
<p>Type something about yourself here. Describe briefly who you are and what you do for a living. Remember to use bold and italic text, for emphasis.</p>
<h2>My favourite Web Sites</h2>
<!-- This list is an unordered list -->
<ul>
<li><a href="http://www.your-name-here.co.uk">Domain Name Registrations</a></li>
<li><a href="http://www.bestdesigns.co.uk">Web Designers In Blackpool</a></li>
<li><a href="http://www.blackpoolhotel.com">Blackpool Hotels</a></li>
</ul>
</body>
</html>
Save the text file as "index.html".