<a href=""> on whole page instead of inside </a> <导航> <a href="">

时间:2018-11-09 17:37:23

标签: html css hyperlink href

I tried making menu with 4 links but one of them can be clicked anywhere on the whole page. I tried looking for unclosed tags but can't seem to find anything. I also tried to use sites that check for code errors and they say that there is unclosed tag but either I'm blind or there are no unclosed tags... :/ I know it's noob question but I'm trying for 20 minutes now to find the unclosed tag? that I can't find.

Edit: about.html opens if I click anywhere on the page

I don't know how to upload files so I'm just pasting code below (I also have some css code but I don't think that CSS is the issue):

<!DOCTYPE html>
<html lang="pl">
<head>
    <meta charset="utf-8" />
    <meta name="description" content="opis strony" />
    <link href="https://fonts.googleapis.com/css?family=Patrick+Hand&amp;subset=latin-ext" rel="stylesheet">
    <link rel="stylesheet" href="Style.css">
    <title> Kurs HTML i CSS3</title>
</head>

<body>
  <div class="container">
      <header>
        <div class="title">
          <h1>Kurs HTML5 i CSS3</h1>
        </div>
        <nav>
            <ul>
              <li><a href="index.html">Start</li>
              <li><a href="html5.html">HTML5</li>
              <li><a href="css3.html">CSS3</li>
              <li><a href="about.html">O mnie</li>
            </ul>
        </nav>
      </header>

      <div class="content">
          <div class="main-content">
                <section>
                    <article id="html5">
                      <h2>Artykuł o HTML5</h2>
                      <figure>
                          <img src="html5.png">
                          <figcaption>Logo HTML5</figcaption>
                      </figure>
                      <p>Witaj na mojej stronie poświęconej HTML5 i CSS3</p>
                    </article>

                    <article id="css3">
                      <h2>Artykuł o CSS3</h2>
                      <figure>
                        <img src="css3.png">
                        <figcaption>Logo CSS3</figcaption>
                      </figure>
                      <p>
                        Przykładowa treść 1 <br>
                        Przykładowa treść 2
                      </p>
                    </article>
                </section>
            </div>


            <div class="sidebar">
                <aside>
                    <h2>JavaScript</h2>
                    <p>Warto wiedzieć, że do tworzenia stron internetowych często wykorzystuje się również język JavaScript.
                      Pozwala on na zaprojektowanie interaktywnych stron internetowych poprzez reagowanie na zdarzenia.</p>
                </aside>
            </div>
        </div>


        <footer>Wszelkie prawa zastrzeżone &copy</footer>
  </div>
</body>

1 个答案:

答案 0 :(得分:0)

问题在这里:

    <nav>
        <ul>
          <li><a href="index.html">Start</li>
          <li><a href="html5.html">HTML5</li>
          <li><a href="css3.html">CSS3</li>
          <li><a href="about.html">O mnie</li>
        </ul>
    </nav>

您应该以这种方式关闭链接文本之后的元素:

    <nav>
        <ul>
          <li><a href="index.html">Start</a></li>
          <li><a href="html5.html">HTML5</a></li>
          <li><a href="css3.html">CSS3</a></li>
          <li><a href="about.html">O mnie</a></li>
        </ul>
    </nav>

如果您不关闭它,则a元素之后的所有内容都在锚元素“内部”

相关问题