Good Day all,
I need some help. Being really silly I think and I bet its a piece of cake but i have 4 buttons on my HTLM website
What I need to know is what do I have to do so when I click on one of those buttons it will take me to that page, or rather scroll down to that section of the website?
Thanks in Advance
You will have to use an
a tag that links to your div. For example:
<a href="#portfolio">Click to go to my Portfolio</a> and somewhere else on your page you should have a div (or another element) with an ID of
portfolio (or anything else you want, matching the
You can get what you are looking for from here - https://www.w3schools.com/html/html_links.asp
Check the “Creating a Bookmark” section from the link above. Here’s a screenshot below.
So, all you need to do is create some content in your page and give it an ID attribute. Then provide the ID value in the anchor tags in your navigation menu.
Hope that helps!
Thanks for the feedback I will try this now.
Is this right:
I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.
Yes, this should be correct.
@BenGitter Awesome thanks
Flip i am not getting this. I have done what was said…
Is there now something I have to do in CSS?
Do you have a CodePen? Or could you copy your code?
this is the link:
this is the link to my code pen. Very basic at the moment.
You would need something like this:
<a href="#test">Click here!</a>
There are two problems here:
- In HTML, any tag that applies to content must enclose the content to which it applies. So
<h1>sometext</h1> will make sometext a heading, but
sometext<h1></h1> won’t. You have your
<a> tags, but they enclose zero content, so the clickable area is zero pixels.
- You’ve used the
id attribute on the buttons themselves, so the links point back to the buttons, not content on the page.
There are also some other problems in your code:
- Styles, metadata, etc. should go inside the
<head> tag, not
<header> “represents a group of introductory or navigational aids” (source). Codepen treats everything you type in the editor as
<body> content anyway (click “Settings” to add
<head> content). A minimal HTML document, meanwhile, consists of
- “Protfolio” -> “Portfolio”
Just use this
<a href="link_to_about_page"><button id="about">About</button></a>
You can also use this, in your button’s code :
this will scroll to your divs elements :
..content of your about div...
<div id="div_contact>..content of your contact...</div>
@djebar-fermas Thank you for the help. I will try it later on this afternoon. Don’t know why i am battling with this.
i think the code should look this way
corret me if am wrong
I forked your pen where u can see how to setup sections and jump to them
Hope that helps !
Wow Awesome. Thank you for that.