Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Anchor Issue

  1. #1
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Anchor Issue

    I'm relatively new to CSS so sorry if this is I'm terrible at explaining.
    I've made many anchor layouts for social networking websites over the years, but this is the first time I've tried to do it for a website i'm coding from scratch.
    My issue is that i'm trying to make something like this; click (when you click the likes, music, etc links it goes to a new section)
    So I want a code that means I can click the headers and it will take me to a new section. With all of the anchor codes i've tried to use, they always just jump down the page to a paragraph. This isn't what I need. I've tried so many different codes and still none of them are giving me the result I want.

    So far in my HTML I have;
    Code:
    <div id="menu">
    			<ul>
    				<li><a href="#home">Home</a></li>
    				<li><a href="#about">About</a></li>
    				<li><a href="#features">Features</a></li>
    				<li><a href="#products">Products</a></li>
    				<li><a href="#contacts">Contact</a></li>
    			</ul>
    		</div>
            <a name="home"></a>
            <div class="anchor">
    I'm sure I need to put something in the css stylesheet to make this work, but i'm not sure what it is that I'll need.
    Any help would be appreciated.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Get rid of the invalid <a name="home"></a> as those tags are no longer allowed to have a name attribute.

    You currently have one anchor in that code - menu - which you don't reference. Simply add the other anchors the same way.

    for example <div id="home" class="anchor">
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •