Reviews and recommendations on this web site, including web hosting reviews, may result in commissions paid to the Dave's Site. Follow on Twitter @firstdave
Check Out my new PhoneGap Tutorial / Cordova Tutorial


Hosting Tutorial - Table of Contents

This course was developed in much earlier days of the web and has been updated into Web Design Basics for iPad (same Dave, much better course!)
iPage Web Hosting -- Go Green for only $1.99/mo.
Web Hosting HTML Tutorial CSS Tutorial Web Design Tutorial Hosting under $5


HTML Code MiniChapter 4: Links and Images

HTML Tutorial Chapters:  

HTML5 Basics - Web Hosting Ideas - CSS, Web Design, HTML, JQuery - Twitter - Learn on your iPad

HTML Anchored Links...

< back to the previous chapter

Without links, the World Wide Web wouldn't be a web at all! To add a link... you will use the <a href="location"> opening tag and </a> closing tag. Whatever appears between these two tags will become underlined and colored, and if you click on the underlined text it will send the browser to the location within the quotes.

Example of a link...

Visit <a href="http://www.davesite.com/">Dave's Site!</a>

Visit Dave's Site!

If you are just linking to a page in the same folder as your current page, you don't need the domain, just the page name.

What do I mean? Okay, imagine you're at your main page, example.com/index.shtml and you're linking to example.com/contactme.html. You can use the code:

<a href="contactme.html">Contact Me</a>

Note: Although links are usually used to send people to other web pages, you may also use links to send email to a specific address by using a location of mailto:user@host.

Example of a Mailto: Link...

Send email to <a href="mailto:webmaster@davesite.com">the Author [Dave]!</a>

Send email to the Author [Dave]!

If you want a link to open in a new window, add target="_blank" at the end of the anchor (<a>) tag.

Example of a link opening in a new window...

<a href="http://dave.kristula.com/" target="_blank">dave.kristula.com</a>

Visit Dave.Kristula.com

Just a warning: Many pop-up blockers will block a _blank link from opening... use with caution!

Five minute intro to CSS, then back to HTML

If you would like to remove the underline from the link, and use special effects such as a link hover, you can use CSS links.

This is detailed in CSS: An Interactive Tutorial for Beginners.

For example, with cascading style sheets (CSS), you'd have a file for your styles, then your HTML file.

In the CSS file (.css), you could use this:

a:hover { color: orange; }

That says, when someone hovers an <a> link (moves the mouse on it), temporarily change the link display color to orange.

The HTML code looks exactly the same, for example, a link to my getting your .com page would be coded like this:

<a href="http://www.davesite.com/webstation/html/domain.shtml">Launch your .com today!</a>

You then link the HTML and CSS file together (this is covered in my CSS course, don't worry about the details until you're finished learning HTML).

The link is now orange when you move your mouse over it, like this:

Launch your .com today!

Move your mouse over the link to see it orange.

Learning CSS is also free, but it requires you to have a strong knowledge of HTML.

Web designers encourage you to first master HTML, then master CSS, then move into JavaScript.

Once you finish this HTML course, I encourage you to hop straight over to CSS: An Interactive Tutorial for Beginners.


HTML In-line Images...

You may also add images (pictures) to your web page, as long as the image is in the .png, .gif, or .jpg (or .jpeg) file formats. You will not be able to use .bmp format files! The basic tag for in-line images is <img src="location">. It is also recommended to add HEIGHT and WIDTH attributes to the IMG tag, which will allow the image to take proper proportions on a browser that is not currently viewing images. It is also recommended to use the ALT="what picture is" to tell a person what a picture is in case it is still loading or they are not viewing images. (The IMG tag has no closing tag!)

Example of a basic in-line image...

<img src="http://www.davesite.com/graphx/davesmll.gif"
width="200" height="50" alt="Dave's Site">

Dave's 
Site

If your image is in the same folder as your HTML file, just use the image name. If your file is welcome.jpg, you can use <img src="welcome.jpg"> Then add the appropriate height, width, and alt attributes as mentioned above.

Combining HTML Links and Images...

Many times you may want to have an image that is linked, so that if someone clicks the image, the person will be taken to another page. This is rather simple- you just need to place the IMG tag within the A HREF tags.

<a href="location_of_link"><img src="location_of_image"></a>

You may also use the ALIGN attributes with images!

Example of a linked image...

<a href="http://www.davesite.com/"><img src="http://www.davesite.com/graphx/davesmll.gif"
align="right"></a>



(Note: Some web browsers place the border automatically, others do not. It's best to set a border to ensure it always shows the way you want.)

If you want to ensure you want the image to be linked without the colored link border, add border="0". Example:

<a href="http://www.davesite.com/"><img src="http://www.davesite.com/graphx/davesmll.gif"
align="right" border="0"></a>



HTML Code - Try it Yourself!

In the Box below, type the following HTML code (or copy and paste) then click "Check it Out!"

The HTML document you made will be displayed in your browser. You may wish to change the words within the tags and the tag attributes just to try it out.

Try typing this:

<html>
<head><title>Title goes here</title></head>
<body>
<h1 align=right>This page tests Links and Images</h1>
<hr>
<p><b>Text links are easy...</b> Visit <a href="http://www.davesite.com/">Dave's Site!</a>
<hr width="50">
and Image Links are not that hard... <a href="http://www.davesite.com/">
<img src="http://www.davesite.com/graphx/davesmll.gif" border=0 /></a></p>
</body>
</html>



iPage has the Best Support

iPage 
has Outstanding Uptime and Performance


HTML An Interactive Tutorial
Continue Next Chapter
Copyright © Dave Kristula. All rights reserved.
URL: https://www.davesite.com/webstation/html/chap04.shtml