Another good use of ISO character entities is for displaying actual HTML
formatting tags on a web page.
If you wanted to show someone how to create a link using a web page as your
tutorial space (hmmmm.... kinda like this site!) you might type the
following into your HTML document:
<A href=http://www.ebay.com> Visit eBay! </A>
but when you went to view it from within a web browser, you would see:
Visit
eBay!
instead of the actual HTML. In order to display the actual HTML link
tags within a web browser,
you would need to substitute character entities for the "lesser than"
and "greater than" tags. Those character entities look like this:
< (which equals the "<" character)
That's an ampersand followed by the lower case letter
"L", the lowercase letter "T" and finally a semicolon.
> (which equals the ">" character)
That's an ampersand followed by the lower case letter
"G", the lowercase letter "T" and finally a semicolon.
By substituting these character entities, you effectively
"break" the ability of the web browser to parse and display the HTML
as an actual link. This is good since your intention is not to create a link,
but to display the HTML needed in order to create a link!
With the character entity substitutions, you would type:
<A href=http://www.ebay.com> Visit eBay! </A>
and the web browser would parse this and display it as:
<A href=http://www.ebay.com> Visit eBay! </A>
SPECIAL QUIZ QUESTION!
When I was a regular on the eBay chat forums, I would use this
character entity trick to display HTML tags for users who had questions about
how to create a link. Other users would notice that I had effectively displayed
HTML tags without the tags being parsed by the web browser. They would ask me,
"how did you do that?" I would then show them how. Again, note that if
I type what I typed to create the "inactive" HTML link:
<A href=http://www.ebay.com> Visit eBay! </A>
that the following would display:
<A href=http://www.ebay.com> Visit eBay! </A>
What would one type into their HTML text document in order to
display the following text inside a web browser?
<A href=http://www.ebay.com> Visit eBay! </A>
HINT! It involves a character entity substitution for one of
the characters within the character entities for < and >
Can you figure it out? If you do, email me with the
answer!
griff@ebay.com
First person to send in the correct answer will be announced
here!
UPDATE! Dec 17, 2001 - And the winner, (Finally! A Winner!) is Eddie
(eBay Id lancashire-lad
)
Eddie wrote:
"...I guess you used the character
&lt; to show <..."
Which is absolutely correct. Eddie wins a
snazzy eBay baseball cap signed by Uncle hisself.
In order to display the actual character
entity without the web browser parsing the entity and displaying the
character, you substitute a character entity for one of the characters
inside the original entity. In this case, we substituted the character
entity for ampersand & for the & character.
This could go on forever in an endless
regression of nested character entities but I will assume you got the point
and will spare you the tedium of actually printing out an endless regression
of nested character entities but I will assume you got
the point and will spare you the tedium of actually printing out an endless
regression of nested character entities but
I will assume you got the point and will spare you the tedium of actually
printing out an endless regression of nested character entities but
I will assume you got the point and will spare you the tedium of actually
printing out an endless regression of nested character entities...
|