HTML Links ? - Ashutosh

Hot

Post Top Ad

Friday, September 22, 2017

HTML Links ?

Hello, Everyone Myself ~ Ashutosh. And today you learn about HTML Links.. Lets start..




HTML uses a hyperlink to link to another document on the web .

Examples : This example demonstrates  how to create links in an HTML document.

<html>
<body>
<p>
<a href="Lastpage.htm">
This text </a> is a link to a page on this Web site.
</p>
<p>
<a href="http://www.microsoft.com/">
This text </a> is a link to a page on the World Wide Web.
</p>
</body>
</html>


Output

This text is a link to a page on this web site.
This text is a link to a page on the World wide Web.

Examples : This Examples demontrates how to use an image as a link.

<html>
<body>
<p>
You can also use an image as a link:
<a href="lastpage.htm">
<img border="0" src="buttonnext.gif" width="65" height="38">
</a>
</p>
</body>
</html>

Output


You can also use a image as a link:

The Anchor Tag and the Href Attribute


HTML uses the <a> (anchor) tag to create a link to another document. An anchor can point to any resource on the Web: an HTML page ,an image,a sound file,a movie ,etc.

   The syntax of creating an anchor:
<a href="url">Text to be displayed </a>

The <a> tag is used to create an anchor to link from the href attribute is used to address the document to link and the words between the open and close of the anchor tag will be displayed as a hyperlink.

This anchor defines a link to W3Schools:
<a href="http://www.W3Schools.com/">Visit W3School!</a>

The Target Attribute

With the target attribute, you can define where the linked document will be opened.

<a href="http://www.w3schools.com/"
target="_blank">Visit W3Schools!</a>

The Anchor Tag and the Name Attribute

The name attribute is used to create a named anchors we can create links that can jump directly into a specific section on a page instead of letting the user scroll around to find what he/she is looking for. Below is the syntax of a named anchor:

<a name="label">Text to be displayed</a>

The name attribute is used to create a named anchor. The name of the anchor can be any text you care to use.

The lines below defines a named anchor:

<a name="tips">Useful Tips Section</a>

You should notice that a named anchor is not displayed in a special way. To link directly to the "tips" section,add a #sign and the name of the anchor to the end of a URL, like this:

<a href="http://www.w3schools.com/html_links.asp#tips">

Jump to the useful Tips section</a>

A hyperlink to the useful Tips section from WITHIN the file "html_links.asp" will look like this:

<a href="#tips">Jump to the useful Tips Section</a>


Basic Notes  -- Useful Tips

Always add a trailing slash to subfolder refrences.If you link like this : href="http://www.w3school.com/html" , You will generate two HTTP requests to the server , because the server will add a slash to the address and create a new request like this : href="http://www.w3school.com/html/"

Named anchors are often used to create "table of contents" at the beginning of a large document. Each chapter within the document is given a named anchor,and links to each of these anchors are put at the top of the document. If a browser cannot find a named anchor that has been specified, it goes to the top of the document. No error occurs.

                                *******
written with Heart 💙

Thanks

Created by Ashutosh


Subscribe ~ Ashutosh000.blogspot.com