"name" attribute in anchor tag

"name" attribute in anchor tag The name attribute is used to create a named anchor.
When using named anchors, you can create links to a specific section on a page, instead of letting your viewer scroll around to see what he/she is looking for.

Example:
In file1.html we have:
<a name="css-tutorials">Go to Home</a>

In file2.html we have:
<a href="file1.html#css-tutorials">Go to CSS Tutorials</a>

Just place the # sign followed by the name attribute value for the file1.html's anchor tag.

Let us take an example:-

In this example, we will create an intra page link which connects the bottom text in a page to the top of the page when clicked on the link
I have created a file test.html

I have created an anchor tag whose name attribute = "top".

The above line specifies a named anchor ,ie., the anchor will be accessed by # sign and the anme attribute's value.

Now we have a long paragraph such that the top anchor is not visible when we are scrolling down to the end of the web page. So, the user needs a mechanism to go the top of the page on one click without scrolling or using the scroll bar ,we write a hyperlink with the #top href attribute.

When the user clicks on the anchor, the screen will automatically scroll up to the top of the page

Comments

Popular posts from this blog

Parallel Database design, query processing

Laravel | PHP | Basics | Part 2

Apache Hadoop | Running MapReduce Jobs