HTML and CSS Reference
In-Depth Information
Here clicking on the text “About” will open the about.html page inside our browser.
Clicking the text “Google,” on the other hand, will open http://www.google.com/
within our browser.
Click here to view code image
1. <!-- Relative Path -->
2. <a href=" /about.html ">About</a>
3.
4. <!-- Absolute Path -->
5. <a href=" http://www.google.com/ ">Google</a>
Linking to an Email Address
Occasionally we may want to create a hyperlink to our email address—for example, hy-
perlink text that says “Email Me,” which when clicked opens a user's default email client
and pre-populates part of an email. At a minimum the email address to which the email is
being sent is populated; other information such as a subject line and body text may also be
included.
To create an email link, the href attribute value needs to start with mailto: followed
by the email address to which the email should be sent. To create an email link to
shay@awesome.com ,
for
example,
the href attribute
value
would
be
mailto:shay@awesome.com .
Additionally, subject, body text, and other information for the email may be populated. To
add a subject line, we'll include the subject= parameter after the email address. The first
parameter following the email address must begin with a question mark, ? , to bind it to the
hyperlink path. Multiple words within a subject line require that spaces be encoded using
%20 .
Adding body text works in the same way as adding the subject, this time using the body=
parameter in the href attribute value. Because we are binding one parameter to another
we need to use the ampersand, & , to separate the two. As with the subject, spaces must be
encoded using %20 , and line breaks must be encoded using %0A .
Altogether, a link to shay@awesome.com with the subject of “Reaching Out” and body
text of “How are you” would require an href attribute value of
Click here to view code image
mailto:shay@awesome.com?subject=Reaching20%Out&body=How%20are%20you
Here's the full breakdown:
Search WWH ::




Custom Search