Page 51 - DCAP408_WEB_PROGRAMMING
P. 51
Unit 2: Creating Static Web Pages
The “alt” attribute tells the reader what he or she is missing on a page if the browser can’t load Notes
images. The browser will then display the alternate text instead of the image.
Task It is a good practice to include the “alt” attribute for each image on a page, to
improve the display and usefulness of your document for people who have text-only
browsers. Explain with suitable examples
2.3.2 Hyperlinks
What makes the web so effective is the ability to define links from one page to another, and to
follow links at the click of a button. A single click can take you right across the world!
Links are defined with the <a> tag.
Let’s create a link to the page defined in the file “peter.html”: This link to
<a href=”Example1.html”>upendra’s homepage</a>.
The text between the <a> and the </a> is used as the caption for the link. It is common for the
caption to be in blue underlined text. It is by the way a good idea to not have any blank spaces
in the names of your HTML files, as this might create problems with some web servers. You can
use an underscore, “_”, to separate words in your file names.
To link to a page on another web site you need to give the full web address (the URL). For
instance, to link to “Google” you need to write:
A link to <a href=”http://www.google.com”>Google</a>.
If you want the user’s browser to open a new window for the linked page, (that way the user
finds back to your page as soon as he or she closes the new window), use the attribute target:
A link to <a href=http://www.google.com target=’_blank’>Google</a>.
Did u know? What are the two attributes in image tag?
The <img> tag has two required attributes: src and alt.
Example: Try the given below code to learn how an hyperlink is inserted in a webpage.
<html>
<body>
<p>
<a href="default.asp">HTML Tutorial</a> This is a link to a page on this
website.
</p>
<p>
<a href="http://www.google.com/">Google</a> This is a link to a website on
the World Wide Web.
</p>
LOVELY PROFESSIONAL UNIVERSITY 45