Home > Software design >  Each .nav-link element should have an href attribute
Each .nav-link element should have an href attribute

Time:10-29

This is a freecodecamp certification question and I will posibly delete the question, answers afterwards not to impose an infringement of any sort, if is.

Heres is all my code:

the test is: Each .nav-link element should have an href attribute. (plain and simple)

header {
  position: fixed;
}

@media only screen and (max-width: 600px) {
  body {
    background-color: lightblue;
  }
}

.flex-container {
  display: flex;
  background-color: DodgerBlue;
}

.flex-container>div {
  background-color: #f1f1f1;
  margin: 10px;
  padding: 20px;
  font-size: 30px;
}
<header id="header">
  <nav id="nav-bar">

    <input href="#board" type="checkbox"  name="board" value="board">
    <label for="board"> I have a board</label><br>

    <input href="#bike" type="checkbox"  name="bike" value="bike">
    <label for="bike"> I have a bike</label><br>

    <input href="#car" type="checkbox"  name="car" value="car">
    <label for="car"> I have a car</label><br>
  </nav>


  <img src="https://external-content.duckduckgo.com/iu/?u=https://logos-world.net/wp-content/uploads/2020/11/KTM-Logo-1953-1954.png&f=1&nofb=1&ipt=83385dd56b355083ae1c3c92f1dfefa29ef039d7fed4bc5b0af0f2d1b41cd179&ipo=images" id="header-img"
    alt="Smiley face" width="100%" height="auto">
</header>

<iframe id="video" src="">
        </iframe>
<section id="board">
</section>
<section id="bike">
</section>
<section id="car">
  <form id="form" action="https://www.freecodecamp.com/email-submit">
    <input id="email" type="email" placeholder="text" name="email"></input>
    <input id="submit" type="submit" placeholder="text"></input>
  </form>
</section>
<iframe id="flex-container" src="">
        </iframe>

Is all the code, ( theres is about 10 -20 that has to pass to get the assignment done...

Can you explain or se the error I cannot and have spend half an hour on this issue, please help. Best regards Alex

I tried rearranging the code in many different ways but I still do not see the error.

CodePudding user response:

You are adding the href in the "input", which doens't accept it. You have two solutions for doing that:

  1. Add input inside tag:

    <a href="#board"> <input type="checkbox" name="board" value="board"> </a>

  2. Using onClick function:

    <input type="checkbox" name="board" value="board" onclick="location.href='#board';" >

  • Related