Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect to a particular section of a page in html

Tags:

html

I am done with redirection to target page but what I want is to redirect to particular <div> of the page. How can this be achieved?

like image 653
Mayank Parnami Avatar asked May 26 '15 12:05

Mayank Parnami


People also ask

How do I redirect a specific section in HTML?

Method 1: Using HTML: One can use the anchor tag to redirect to a particular section on the same page. You need to add ” id attribute” to the section you want to show and use the same id in href attribute with “#” in the anchor tag.

How do I redirect one page to another page in HTML?

To redirect one HTML page to another page, you need to add a <meta> tag inside the <head> section of the old HTML page.

How do you link to the bottom of a page in HTML?

An <a> tag can also be used to mark a section of a web page as a target for another link to jump to. For example, this link will jump to the bottom of this page. If the "name" and "id" attribute is used, the <a> tag is an anchor, but if the "href" attribute is used then it is a link.


1 Answers

You can do it in two ways.

1) [via Javascript (+jQuery)]

<a href="#" id="home">home</a>

$('#home').click(function(){
$(document).scrollTop(100) // any value you need
});

2) [via pure HTML]

<a href="#home_section">home</a>

<section id="home_section"></section>
like image 108
Ajai Avatar answered Oct 04 '22 21:10

Ajai