Skip navigation
BLOG  |  APRIL, 2009

How to create a link in html

April 20, 2009 at 5:03 PM
by George

To create a link within your website
This is the code you need if you are trying to link to a page that is on your site.
<a href="page2.html">This is a link</a>

Example: This is a link to "newfangled_employee_blogs"

Linking to an external site.
To make a link that that redirects to an external site, the href must begin with http://
<a href="http://cnn.com" >Link to CNN</a>

 

Example: This is a link to an external site

Link that opens up in either a new window or new tab.
This is the code you need to make a link open up in a new window or a new tab depending on what browser you are using.
<a href="page2.html" target="_blank">This is a link that opens up in either a new window or new tab</a>

Example: This is a link that opens up in a new window / tab

How to make a link that opens up in a new window (popup).
To make a link open up in a new window (popup), here is the code.
<a target="_blank" onclick="window.open ('page2.html','_blank', 'status=1, toolbar=0, location=0, menubar=0, resizable=1, left=20, top=50, width=90, height=90');
 return false;" href="#">Test Popup 3</a>

Example: This is a popup link

Here is some of the optional stuff that one can specify for the new window by either specifying 0 or 1.
Please note: In programming, "0" means false, "1" means true.

toolbar=0hide/show the toolbar
status=1hide / show the status bar
location=0hide/show the address/location bar
menubar=1hide/show the menu bar
resizable=0is the popup window resizeable
left=200position the popup 200 pixels from the left
top=250position the popup 250 pixels from the top
width=300width of the popup
height=400height of the popup


If you are specifying more than one item, you must separate each item by a comma (as shown in the example above).


Comments
Jillian Kuhn | April 21, 2009 4:36 PM

Thanks for that, George! We were just talking about links that open up new windows-- and now I don't have to look up the code!