<a href="URL_of_the_destination_file#something-special">
Read even more.</a>
Maria: I suppose the destination file is the file containing th e id of something-
special?
Professor: Exactly.
You will occasionally notice a hash sign (#) alone. Authors sometime s use it as a
placeholder in web temp la te s where actual destinations of the links are not known at
the time of writing c ode. Such links, when followed, simply reload the current page .
Maria: Could I use the <a> e le ment for an image gallery? For examp le , to make a
clickable thumbnail that would behave like a hyperlink to a larger photo?
Professor: Of course. The HTML5 standard poses no limits as to what the content
of this element may be, so long as it is not interactive. For example, y ou cannot nest
a button or an other link within a hyperlink. This limitation is understandable since
placing interactive co ntent inside the element that is itself inte ractive would present a
conflict of interests. Otherwise, the <a> element can contain entire paragraphs, tables,
and even e ntire articles.
A question for y ou. In the following code, w hich is a thumbnail and which is a full-
size photo?
<a href="A.jpg"><img src="B.jpg"></a>
Maria: The destination of the link is the A.jpg file. Therefore, this must be the large
photo.
B.jpg is the source for the image displayed on the page, which must be the
thumbnail.
Professor: Great! We are ready to move on.
2.6 Character Entities
Professor: Consider this HTM L:
The notation x<y means that x is less than
y, while x>y means that x is greater than y.
Let’s view it in the browser.
What do you think happ ened?
2.6. Character Entities 31
Maria: It seems that the browser ignores everything between the angle brackets in-
cluding the brackets themselves.
Professor: Good observation. What the br owser is ac tually ignoring here is an un-
known tag. HTML is a computer lang uage, wh ic h follows a certain well defined set
of rules that we call syntax. Tho se rules come in the form of combinations of dierent
symbols that define certain comm ands. They tell a computer w hat ne eds to be done.
For example, a left ang le bracket (<) im mediately followed by some text followed
by a right angle bracket (>) is an opening tag—a message to the browser that a new
element has started. The tag itself is not displayed. The browser d oes not display the
tag even if it does not recognize it. An unrecogniz ed tag is silently ignored.
Let’s go back to our example. The problem is not that the tag isn’t reco gnized by
the browser, since we didn’t use any tag in the first pla ce. T he less-than sign has a
special meaning for the browser, which interprets it as the beginn ing of an opening tag
rather than displaying it. A character that has a special (reserved) meaning is called
a reserved character. To be able to display reser ved characters, HT ML has defined
additional syntax rules called character e ntities. Character entities are not limited
only to the re served characters, thou gh. They can be used to display any character.
For example, a character that is not present on your keyboard.
The syntax for a characte r entity is an ampersand (&) followed by an entity name
followed by a semicolon (;):
&entity_name ;
All browsers should support at least th ese five cha racter entities:
Display Chara cter Entity Name Description
< lt less than
> gt greater than
& amp ampersand
" quot quotation mark
apos apostrophe
Note that the en tity names are case sensitive. There are of course tons of other char-
acter entities. If you are interested in experimenting with them, I encourage you to
search tables of ch aracter entities on the Web.
Now we are ab le to rewrite our last example:
The notation x&lt;y means that x is less than
y, while x&gt;y means that x is greater than y.
Instead of entity names, you can also use entity num bers, to wh ic h you should prepend
an additional hash (#) character. Using an entity number, a character entity can be
expressed in the form:
32 Meeting 2. Building a Sound Structure
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.205.169