HTML Character Entities
Some characters like the < character, have a special meaning in HTML, and therefore cannot be used in the text.
To display a less than sign (<) in HTML, we have to use a character entity.
Character Entities
Some characters have a special meaning in HTML, like the less than sign (<) that defines the start of an HTML tag. If we want the browser to actually display these characters we must insert character entities in the HTML source.
A character entity has three parts: an ampersand (&), an entity name or a # and an entity number, and finally a semicolon (;).
To display a less than sign in an HTML document we must write: < or <
The advantage of using a name instead of a number is that a name is easier to remember. The disadvantage is that not all browsers support the newest entity names, while the support for entity numbers is very good in almost all browsers.
Note that the entities are case sensitive.
This example lets you experiment with character entities: Character Entities
Character entities
&X;
Substitute the "X" with an entity number like "#174" or an entity name like "pound" to see the result.
Non-breaking Space
The most common character entity in HTML is the non-breaking space.
Normally HTML will truncate spaces in your text. If you write 10 spaces in your text HTML will remove 9 of them. To add spaces to your text, use the character entity.
The Most Common Character Entities:
| Result | Description | Entity Name | Entity Number |
| non-breaking space | |||
| < | less than | < | < |
| > | greater than | > | > |
| & | ampersand | & | & |
| " | quotation mark | " | " |
| ' | apostrophe | ' (does not work in IE) | ' |
Some Other Commonly Used Character Entities:
| Result | Description | Entity Name | Entity Number |
| ¢ | cent | ¢ | ¢ |
| £ | pound | £ | £ |
| ¥ | yen | ¥ | ¥ |
| € | euro | € | € |
| § | section | § | § |
| © | copyright | © | © |
| ® | registered trademark | ® | ® |
| × | multiplication | × | × |
| ÷ | division | ÷ | ÷ |
HTML Links
HTML uses a hyperlink to link to another document on the Web.
Examples
Create hyperlinks
This example demonstrates how to create links in an HTML document.
This example demonstrates how to create links in an HTML document.
This text is a link to a page on
this Web site.
This text is a link to a page on
the World Wide Web.
An image as a link
This example demonstrates how to use an image as a link.
This example demonstrates how to use an image as a link.
You can also use an image as a link:
(You can find more examples at the bottom of this page)
The Anchor Tag and the Href Attribute
An anchor can point to any resource on the Web: an HTML page, an image, a sound file, a movie, etc.
The syntax of creating an anchor:
The tag is used to create an anchor to link from, the href attribute is used to address the document to link to, and the words between the open and close of the anchor tag will be displayed as a hyperlink.
This anchor defines a link to W3Schools:
The line above will look like this in a browser:
The Target Attribute
With the target attribute, you can define where the linked document will be opened.
The line below will open the document in a new browser window:
The Anchor Tag and the Name Attribute
The name attribute is used to create a named anchor. When using named anchors we can create links that can jump directly into a specific section on a page, instead of letting the user scroll around to find what he/she is looking for.
Below is the syntax of a named anchor:
The name attribute is used to create a named anchor. The name of the anchor can be any text you care to use.
The line below defines a named anchor:
You should notice that a named anchor is not displayed in a special way.
To link directly to the "tips" section, add a # sign and the name of the anchor to the end of a URL, like this:
A hyperlink to the Useful Tips Section from WITHIN the file "html_links.asp" will look like this:
Basic Notes - Useful Tips
Always add a trailing slash to subfolder references. If you link like this: href="http://www.w3schools.com/html", you will generate two HTTP requests to the server, because the server will add a slash to the address and create a new request like this: href="http://www.w3schools.com/html/"
Named anchors are often used to create "table of contents" at the beginning of a large document. Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the document.
If a browser cannot find a named anchor that has been specified, it goes to the top of the document. No error occurs.
More Examples
Open a link in a new browser window
This example demonstrates how to link to another page by opening a new window, so that the visitor does not have to leave your Web site.
This example demonstrates how to link to another page by opening a new window, so that the visitor does not have to leave your Web site.
If you set the target attribute of a link to "_blank",
the link will open in a new window.
Link to a location on the same page
This example demonstrates how to use a link to jump to another part of a document.
This example demonstrates how to use a link to jump to another part of a document.
Chapter 1
This chapter explains ba bla bla
Chapter 2
This chapter explains ba bla bla
Chapter 3
This chapter explains ba bla bla
Chapter 4
This chapter explains ba bla bla
Chapter 5
This chapter explains ba bla bla
Chapter 6
This chapter explains ba bla bla
Chapter 7
This chapter explains ba bla bla
Chapter 8
This chapter explains ba bla bla
Chapter 9
This chapter explains ba bla bla
Chapter 10
This chapter explains ba bla bla
Chapter 11
This chapter explains ba bla bla
Chapter 12
This chapter explains ba bla bla
Chapter 13
This chapter explains ba bla bla
Chapter 14
This chapter explains ba bla bla
Chapter 15
This chapter explains ba bla bla
Chapter 16
This chapter explains ba bla bla
Chapter 17
This chapter explains ba bla bla
Break out of a frame
This example demonstrates how to break out of a frame, if your site is locked in a frame.
This example demonstrates how to break out of a frame, if your site is locked in a frame.
Locked in a frame?
Create a mailto link
This example demonstrates how to link to a mail message (will only work if you have mail installed).
This example demonstrates how to link to a mail message (will only work if you have mail installed).
This is a mail link:
Note: Spaces between words should be replaced by %20 to ensure that the browser will display your text properly.
Create a mailto link 2
This example demonstrates a more complicated mailto link.
This example demonstrates a more complicated mailto link.
