How to go to a part of a text on the same page by clicking on a link above

Posted on

Question :

Imagine a page with lots of text. What I want to do is make a clickable word that when the user clicks it goes to another text on the same page.

I want to do this using XHTML and CSS.

I have at least one idea that XHTML is used # but I can not remember how it’s done.


Answer :

It’s called anchor link

Example with div:

<div id="tips">Useful Tips Section</div> <!-- crie um ID para a div ou span -->

Or with another link:

<div id="tips">Useful Tips Section</div>

Calling another link to the position of the previous div or link:

<a href="#tips">Visit the Useful Tips Section</a> <!-- Utilize esta Id com # no link para ir até este local -->

Calling the link on another page:

<a href="">Visit the Useful Tips Section</a>

Here you need to pass the complete url of the site, because you are using it in another location, another site, etc., but it works, it will point exactly to div id = "tips"

Source: link


<section id ="top">Texto</section>

<a href="#top">Clique aqui</a>

The link goes to the section.


Just by using section to place the text you want to link and put a id in this section :

<section id="minhaTag">
    <!-- o meu texto -->

Then just use this id in the reference word for the text:

<a href="#minhaTag">Palavra de link para o texto</a>


Leave a Reply

Your email address will not be published. Required fields are marked *