HTML and CSS Reference
In-Depth Information
Click here to view code image
1. <a href=" mailto:shay@awesome.com?subject=
Reaching20%Out&body=How%20are%20you ">Email Me</a>
Opening Links in a New Window
One feature available with hyperlinks is the ability to determine where a link opens when
clicked. Typically, links open in the same window from which they are clicked; however,
links may also be opened in new windows.
To trigger the action of opening a link in a new window, use the target attribute with
a value of _blank . The target attribute determines exactly where the link will be dis-
played, and the _blank value specifies a new window.
To open http://shayhowe.com/ in a new window, the code would look like this:
Click here to view code image
1. <a href="http://shayhowe.com/" target="_blank" >Shay Howe</a>
Linking to Parts of the Same Page
Periodically we'll see hyperlinks that link to part of the same page the link appears on. A
common example of these same-page links are “Back to top” links that return a user to the
top of a page.
We can create an on-page link by first setting an ID attribute on the element we wish to link
to, then using the value of that ID attribute within an anchor element's href attribute.
Using the “Back to top” link as an example, we can place an ID attribute value of top on
the <body> element. Now we can create an anchor element with an href attribute value
of #top , pound sign and all, to link to the beginning of the <body> element.
Our code for this same-page link would look like the following:
Click here to view code image
1. <body id="top" >
2. ...
3. <a href="#top" >Back to top</a>
4. ...
5. </body>
Hyperlinks are incredibly useful and have revolutionized how we use the Internet. So far
we've covered how to link to other pages or websites, as well as how to create email links
and links to parts of the same page. Before we go any further, let's create some links of our
own.
Search WWH ::




Custom Search