4.1 Links
Any object such as text, graphic images etc. that leads us to a new page on the web is called a
link. Links can point to a page on our site or to a web page on another site.
In this lesson we will learn how to make links.
4.2 Text links
Creating a text link is an easy task. We will use <a> </a> tag to do this. As before we will need
extra parameters from
this tag. Look at example below :
Example 4.1:
1 2 3 4 5 6 7 8 |
<html> <head> <title>example 4.1</title> </head> <body> <a href="https://www.mywebcode.com/">click here to visit mywebcode</a> </body> </html> |
Above code will create a link that clicking on it will send the user to Yahoo website. We have used
HREF parameter to specify destination web page. Text between <a> and </a> is link text which user will click on it to go to destination page.
4.3 Image links
In previous section we used a text as a link point. It is possible to use an image instead of text. To
do this, you must replace link text between <A> and </A> with an <IMG> tag that displays an
image file.
1 2 3 4 5 6 7 8 9 10 11 |
<html> <head> <title>example 4.1</title> </head> <body> click on below picture to visit my homepage.<br><br> <a href="https://www.mywebcode.com/"> <img src="mywebcode.png"> </a> </body> </html> |
In above example clicking on picture will bring surfer to the address of <a href=”..”> tag.
If you see the result in a browser you will notice a blue border around the picture. This blue border
added to image because it is a default for image links. If you don’t want this border, use border=0
parameter.
Example 4.2:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<html> <head> <title>example 4-2</title> </head> <body> click on below picture to visit my homepage.<br><br> <a href="https://www.mywebcode.com/"> <img src="mywebcode.png"> </a> <br><br>without link border : <br><br> <a href="https://www.mywebcode.com/"> <img src="mywebcode.png" border=0> </a> </body> </html> |
4.4 Email links
If you have surfed web for a while you have seen links that when you click on them your email
program starts a “compose new message” window that its receiver address is entered from web
page . This email address is the address you want email to be sent to.
Look at example below to see how you can make a link to an email address.
1 2 3 4 5 |
<body> Click on below link to send an email to me <br> Email me</a> </body> |
It uses a “mailto:” string before desired email address to convert it into a link address.
If you want, you can use a subject for the email. This example will show you how to do this :
Example 4.3:
1 2 3 4 5 6 7 8 9 10 |
<html> <head> <title>Example 4.2</title> </head> <body> click on below link to send us your comments .<br> subject:comments about your site">email me</a> </body> </html> |
Just know that some browsers and email programs do not support subject in email links.
4.5 Lists
There are times that you want to insert items related to a subject in list form in your web page.
HTML provides you with tags to do this. <ul> </ul> tags are first choice of these tags.
Example 4.4:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<html> <head> <title>example 4.3</title> </head> <body> this is a list of subjects covered in this lesson : <ul> <li>text links <li>image links <li>email links <li>list of items </ul> </body> </html> |
Result page will display list items in separate lines started with a small bullet. you see that we
have entered list items started with a <li> tag between <ul></ul> tags. <ul> tag is a part of
list tags.
If you want the items to start with numbers instead of bullets, you must use <ol></ol> tags
instead of <ul></ul> tags.
1 2 3 4 5 6 |
<ol> <li>text links <li>image links <li>email links <li>list of items </ol> |
Be sure to write down codes in a file and view it with a browser.
4.6 Horizontal Separator Rule
Another useful html tag that you will use, is <hr> tag. If you need to separate text in your web
page by horizontal lines , you may use this tag.
1 2 3 4 5 |
<body> first section <hr> second section </body> |
Result is two lines of text separated by a horizontal rule. You can specify parameters for horizontal
rule. If you want to change width of rule you can use width parameter.
<hr width=”50%”> width in percent
<hr width=”100″> width in pixels
You can also determine line size parameter to change line diameter.
<hr size=5>
It is obvious that you can mix parameters with each other.
Horizontal rule created by this tag is a line that has a shade. you can change the rule to a solid line
instead of a shaded line, you can add a noshade parameter.
<hr size=1 noshade>
You can also determine color for your line:
<hr color=”#000000″>
Above line will not have a shade and it is a solid line.
4.9 End
In this lesson you learned how to use text links, image links, email links, lists and horizontal rule.
Until now we have covered general HTML tags. In next lesson we will cover more. We will then
start more advanced subjects such as tables, frames and forms in next lessons.
Now you must be able to design simple home pages. So why not start ?
Notice:
- Create a page with a link in it that points to mywebcode site. Center the link in screen center. Use
what you learned about paragraphs in previous lesson. - Change above example to use an image as a link that points to mywebcode site. Remove blue border
around the picture. - Insert both of the exercises above in a single page and separate text link from image link by a
solid green line with 50% of the screen width. - Create a complete contact page (html code) for yourself. People visiting this page must be able
to send you comments about your homepage. - Create a complete web page that contains a numbered list of courses you are interested to find
on the internet.
Learn Free Web Design Courses with Online in 5 days students are learning Web Design on Udemy. Free learning on Udemy. Web Design for … HTML, CSS and JavaScript: The Complete Web Developer Course. Online