How to use links in HTML

August 10, 2009 by admin  
Filed under General

How to create links to different pages in html?

How to use a image as link?

Link: <a> </a> <a href=” “></a>

Lets us consider you have two pages test.html and test1.html.
You want to give a link in test.html so that others can click on it and go to test1.html.
The tag used is “a” with attribute named “href”

Example Code:
<a href=”test1.html”> Click to test1.html </a>
Result:
Click to test1.html

So the tag should be used as above.
The text in between the tag will be displayed on the page.
On clicking the text the user will be taken to the page defined in the attribute href


Link using Images:

Even images can be used for creating links.
Its simple.
Give the image in between the “a” tags.

Example Code:
<a href=”test1.html”> <img src=”./test.jpg”> </a>
Result:

You can see. Its so simple.
In the previous case we gave the text as link.
Now we have given image as a linking code.

I want to create links that will open the pages in new window?

How can I link to website?

Opening link in new page:

Many a times we want to open the links in new window.
It’s simple.
Use the attribute “target=_blank” inside the tag “<a>”.

Example Code:
<a href=”test1.html” target=”_blank”> Click to test1.html </a>
Result:
Click to test1.html

Click on the link to test. It will open the page in new window.


How can I link to an external website?:

The tag is same as other, only thing is that we have to use “http://”.
So to link to google.com we have to use “http://www.google.com”.

Example Code:
<a href=”http://www.google.com”> Google </a>
Result:
Google

This will take you to the website.

I want to create links that can be used for mailing?

How to create a mailto link?

HTML Email:

Its simple.
In the href attribute we have to use the text “mailto”.
Format will be as “mailto:” then mailid.

Example Code:
<a href=”mailto:test@test.com“> Click to email </a>

Result:
Click to email


Creating a link that doesn’t go anywhere:

You can create a link that will not go to any page when you click on it

Example Code:
<a href=”#nowhere”> No Destination </a>

Result:
No Destination

  • Share/Bookmark

Images

August 10, 2009 by admin  
Filed under General

How to insert a image in html?

Tag to set image border html?

I want to set image in both left and right ends in the same line?:

Image Tag:
<img>

To insert a image in your a page we need to use the tag “img” with its attribute “src”
Example Code:
<img src=”test.jpg”>

Result:

Here we assume that we have the image file in the same directory of the html file.
We can also give the full path of the directory as
Example:
<img src=”C:\images\test.jpg”>

Width and Height:
We can resize images that are displayed in web pages using the attributes width and height.
Example Code:
<img src=”test.jpg” width=100 height=100>
Result:

Alignment:
We can align the image using the attribute “align”.
The attribute takes values left or right or center.
Example Code:
<img src=”test.jpg” align=left> <img src=”test.jpg” align=right>
Result:

Borders:
We can set border around images using the attribute “border”. This can be used to create a space around the picture.
Example Code:
<img src=”test.jpg” border=4>
Result:

  • Share/Bookmark