Help needed please with HTML

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
HOME,ABOUT,PORTFOLIO,CONTACT
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
Justin

1 Like

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 href="#[ID-of-element]" part).

Hi! :slight_smile:

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!

Cheers,
Nitin

1 Like

@NitinNair89 @BenGitter

Thanks for the feedback I will try this now.

Is this right:

  <button id="about">About</button>
  <a href="#about"></a>

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.

1 Like

Simple example: http://codepen.io/benjaminvanzwienen/pen/Npvwmm

@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:
@BenGitter
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>
<div id="test"></div>

There are two problems here:

  1. 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.
  2. 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:

  1. Styles, metadata, etc. should go inside the <head> tag, not <header>. <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 <!DOCTYPE HTML><html><head></head><body></body></html>.
  2. “Protfolio” -> “Portfolio”
1 Like

Just use this

<a href="link_to_about_page"><button id="about">About</button></a>

Hi,
You can also use this, in your button’s code :

Home
About
...
Contact

this will scroll to your divs elements :

..content of your about div...
<div id="div_contact>..content of your contact...</div> </pre>

@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
About
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.