|
Sams Teach Yourself Creating Web Pages All in One Authors: Gralla P., Brown M. Published year: 2006 Pages: 21-22/276 |
5 . About Using Special Characters
BEFORE YOU BEGIN 2 Use HTML Tags
SEE ALSO 6 About Proper HTML Coding There are certain characters and symbols that you can type into your word processor, but that won't display on a web page. For example, if you put the symbol for copyright ‚ into the text on a web page, it won't display properly. The same holds true for many other symbols and characters, such as letters in a foreign language such as ƒ § . In order for those special characters and symbols to be displayed on a web page, you'll need to use special code. You denote the special code by prefacing it with a & symbol. Then following the & symbol, you use a name code or a numeric code that will tell the web browser exactly which symbol to display. For a name code, you just type in a name , but for a numeric code, you have to put a # after the & and before the number. Then directly after that name code or numeric code, you place a semicolon ; with no space between it and the code. For example, to display the ‚ symbol on a web page, you would use the coding © or © Each will work, so whichever you want to use is up to you.
NOTE There have been several versions of HTMLthe version is now up to 4.01and along the way the powers-that-be at the W3C introduce new tags and attributes into the language, and try to expunge some tags and attributes that it believes are no longer useful. A tag or attribute that the W3C discourages from being used is called deprecated . These tags and attributes will still work in browsers, but the W3C prefers that coders instead use new tags or techniques. Many deprecated tags, however, remain in widespread use. For example, the nearly ubiquitous FONT tag is a deprecated tag. The W3C prefers that coders use what are called style sheets to determine fonts, rather than using the FONT tag. Note that not every special character has a name code as well as a numeric code, although all have numeric codes. One other reason you'll want to use these special characters to display text is that browsers interpret certain symbol instructions or tags, and so won't display them. For example, let's say you want to display the text <P> on a web page. If you type in The tag <P> starts a new paragraph . your browser will display the following image, which is not at all what you want it to do. Here's what your browser will display if you type The tag <P> starts a new paragraph. Instead, you should type in The tag <P> starts a new paragraph ., which will display the following: When you type The tag <P> starts a new paragraph. , this is what the browser displays. For a list of special characters and symbols, and the codes you need to use for them, go to http://www.w3.org/TR/html401/sgml/entities.html. |
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 Authors: Gralla P., Brown M. Published year: 2006 Pages: 21-22/276 |