NHS Designs
Web Design
HTML

HTML 13: Character entities

how do you put a tag into the text of a web page?

You're right.

Because browsers use the < and > to begin and end tags, using them in the content of your HTML can cause problems.

But, HTML gives you an easy way to specify these and other special characters using a simple abbreviation called a character entity.

Here's how it works: for any character that is considered "special" or that you'd like to use in your Web page, but that may not be a typable character in Notepad (like a copyright symbol ©), you just look up the abbreviation and then type it into your HTML.

For example, the > character's abbreviation is &gt; and the < character's is &lt; .

So, say you wanted to type "The <html> element rocks." in your page. Using the character entities, you'd type this instead:

The &lt;html&gt; element rocks.

Another important special character you should know about is the & character. If you'd like to have an & ("ampersand") in your HTML content, use the character &amp; instead of the & character itself.

So what about the copyright symbol? And all those other symbols and foreign characters? You can look up common ones here:

http://www.w3schools.com/tags/ref_entities.asp

 

Exercise: Crack the Location

Dr Evel, in his quest for world domination, has put up a private Web page to be used by his evil henchmen.

You've just received a snippet of intercepted HTML that may contain a clue to his whereabouts. Given your expert knowledge of HTML, you've been asked to crack the code and discover his location.

Here's a bit of the text from his home page:

crack the location - character entities

  • Type in the HTML and see what your browser displays.
  • Save the file as location.html in your root folder.
  • Turn in your root folder to
    My Documents \ K201 \ PERIOD3/4 \ HTML 13

 

Back to Tony

Tony is happy

We'll learn all about getting a Web site onto the Web in the next few lessons.

First, let's review the main concepts from HTML 80 through HTML 13

Source: "Head First HTML: with CSS & XHTML" by Elisabeth Freeman and Eric Freeman


ABOUT MISS PEDERSEN · EMAIL MISS PEDERSEN
copyright information · Natomas High School Design Department