user3261619
user3261619

Reputation: 3

html code links where it should not?

My problem here is that I have a menu i made in html with some links in the body but when i got to make another tag after the nav tag the last link Contact seems to still keep linking without me doing so. I looked around on google and couldn't seem to find anything where the link persists without me linking it specifically in a . I feel like it is most likely to do with my understanding of the fundamentals since i started html recently. Here is the code:

<html>

    <head>
        <title>Company</title>
        <link rel="stylesheet" href="Style.css">
    </head>

    <body>
        <nav id="menu">
            <ul>
                <li><a href="Home.html">Home</li>
                <li><a href="Products.html">Products</li>
                <li><a href="About Us.html">About us</li>
                <li><a href="Contact.html">Contact us</li>
            </ul>
        </nav>
        <h1>1</h1>
    </body>

</html>

My stylesheet, if the problem occured there?:

#menu nav{
    position:fixed;

    margin:0;
    padding:0;
    border:0;

}

#menu ul{
    list-style:none;
    margin:0;
    padding:0;
    display:flex;
    border:2px;
    border-style:solid;
    background-color:#ccc;
    justify-content:space-around;
}

#menu ul li{
    display:inline;

    margin:0;
    padding:0;
}

#menu li a{
    display:inline-block;
    list-style:none;
    margin:0;
    padding:0;
    border:0;
    text-decoration:none;
    font-size:2em;
    color:blue;
}

#menu li a:hover{
    margin:0;
    padding:0;
    border:0;
    text-decoration:underline;
    color:#cdg;

}

Upvotes: 0

Views: 41

Answers (3)

Squeakasaur
Squeakasaur

Reputation: 245

You are missing your closing for each of your links.

Update:

<li><a href="Home.html">Home</li>
<li><a href="Products.html">Products</li>
<li><a href="About Us.html">About us</li>
<li><a href="Contact.html">Contact us</li>

To:

<li><a href="Home.html">Home</a></li>
<li><a href="Products.html">Products</a></li>
<li><a href="About Us.html">About us</a></li>
<li><a href="Contact.html">Contact us</a></li>

Upvotes: 5

user6864832
user6864832

Reputation:

You are missing the closing tag of </a> and it should be as below code

        <li><a href="Home.html">Home</a></li>
        <li><a href="Products.html">Products</a></li>
        <li><a href="About Us.html">About us</a></li>
        <li><a href="Contact.html">Contact us</a></li>

Upvotes: 1

chris cozzens
chris cozzens

Reputation: 517

You are using a tags which generally designate a link. by adding href="some location" this will make it so that when clicking on the text, you are redirected to that link.

If you remove the href="Contact.html" it will not link anywhere.

You also need to end your links, add a closing a tag before the closing li tag on each line

Upvotes: 1

Related Questions